Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crucible-llvm: Don't crash when simulating llvm.dbg.assign intrinsic #1204

Closed
RyanGlScott opened this issue May 24, 2024 · 0 comments · Fixed by #1205
Closed

crucible-llvm: Don't crash when simulating llvm.dbg.assign intrinsic #1204

RyanGlScott opened this issue May 24, 2024 · 0 comments · Fixed by #1205

Comments

@RyanGlScott
Copy link
Contributor

The llvm.dbg.assign intrinsic was introduced in LLVM 16 and replaces the llvm.dbg.declare intrinsic in LLVM 17. In order to support LLVM 17, we will need to teach crucible-llvm about it. For example, crux-llvm will fail to process this program (when building on top of the llvm-pretty-bc-parser changes from GaloisInc/llvm-pretty-bc-parser#261):

__attribute__((noinline)) int foo(int x[2]) {
  return x[0];
}

int main(void) {
  int x[2] = { 0, 0 };
  return foo(x);
}
$ PATH=~/Software/clang+llvm-17.0.2/bin:$PATH cabal run exe:crux-llvm -- test.c
[Crux] Using pointer width: 64 for file crux-build/crux~test.bc
[Crux] Simulating function main
[Crux] Attempting to prove verification conditions.
[Crux] *** debug executable: results/test/debug-0
[Crux] *** break on line: 0
[Crux] Found counterexample for verification goal
[Crux]   test.c:0:0: error: in main
[Crux]   unsupported LLVM value: ValMd (ValMdValue (Typed {typedType = PrimType (Integer 1), typedValue = ValUndef})) of type metadata
[Crux] Goal status:
[Crux]   Total: 1
[Crux]   Proved: 0
[Crux]   Disproved: 1
[Crux]   Incomplete: 0
[Crux]   Unknown: 0
[Crux] Overall status: Invalid.

In order to make this work, we need to alter the special-casing for llvm.dbg.* intrinsics here. For now, it will suffice to skip calls to llvm.dbg.assign intrinsic, just like most other llvm.dbg.* intrinsics are skipped. If someone wants to reason about the contents of llvm.dbg.assign in a way similar to how other code reasons about llvm.dbg.declare (e.g., how it's done in SAW here), then someone will need to add an LLVM_Dbg_Assign data constructor (similar to the existing LLVM_Dbg_Declare data constructor). I don't have a need for LLVM_Dbg_Assign just yet, so I propose not doing this until someone needs it.

RyanGlScott added a commit that referenced this issue May 24, 2024
….assign

This adds `llvm.experimental.noalias.scope.decl` and `llvm.dbg.assign` to the
list of LLVM intrinsics that `crucible-llvm` skips over during simulation.
Doing so unlocks more support for recent LLVM versions.

It is conceivable that we may want to reason about these intrinsics at a deeper level some
day. If so, see:

* #1196 (comment) for
  how this would be done for `llvm.experimental.noalias.scope.decl`
* #1204 (comment) for how
  this would be done for `llvm.dbg.assign`

Fixes #1196. Fixes #1204.
RyanGlScott added a commit that referenced this issue May 24, 2024
….assign (#1205)

This adds `llvm.experimental.noalias.scope.decl` and `llvm.dbg.assign` to the
list of LLVM intrinsics that `crucible-llvm` skips over during simulation.
Doing so unlocks more support for recent LLVM versions.

It is conceivable that we may want to reason about these intrinsics at a deeper level some
day. If so, see:

* #1196 (comment) for
  how this would be done for `llvm.experimental.noalias.scope.decl`
* #1204 (comment) for how
  this would be done for `llvm.dbg.assign`

Fixes #1196. Fixes #1204.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant