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

llvm_load_module: FUNC_CODE_INST_ATOMICRMW not implemented #228

Closed
ctz opened this issue Sep 17, 2017 · 10 comments
Closed

llvm_load_module: FUNC_CODE_INST_ATOMICRMW not implemented #228

ctz opened this issue Sep 17, 2017 · 10 comments
Labels
type: enhancement Issues describing an improvement to an existing feature or capability
Milestone

Comments

@ctz
Copy link

ctz commented Sep 17, 2017

I'm just getting started with saw/crucible. I can't seem to load my bitcode:

✓ jbp@debian ⎇ master= ~/rustls$ export PATH=$PATH:~jbp/saw-0.2-2017-09-15-Ubuntu14.04-64/bin

✓ jbp@debian ⎇ master= ~/rustls$ cat basics.saw
llvm <- llvm_load_module "rustls.bc";

✓ jbp@debian ⎇ master= ~/rustls$ saw basics.saw
Loading module Cryptol
Loading file "/home/jbp/rustls/basics.saw"
saw: user error ("llvm_load_module" (/home/jbp/rustls/basics.saw:1:9):
not implemented
from:
	FUNC_CODE_INST_ATOMICRMW
	_ZN4core4sync6atomic10atomic_add17hcb98728e357b46d4E
	FUNCTION_BLOCK
	FUNCTION_BLOCK_ID
	MODULE_BLOCK
	Bitstream
)

This bitcode is generated by rustc 1.20.0, which AIUI is based on LLVM 4.0.

@atomb
Copy link
Contributor

atomb commented Sep 20, 2017

Ah, yeah, it looks like the atomicrmw instruction isn't being parsed yet. Thanks for pointing it out!

@atomb atomb added this to the 0.3 milestone Feb 5, 2018
@atomb atomb self-assigned this Feb 9, 2018
@atomb atomb added the type: enhancement Issues describing an improvement to an existing feature or capability label Jun 13, 2018
@robdockins
Copy link
Contributor

We should now be able to parse atomicrmw given some recent work on improving our bitcode parser. Unfortunately, the attached bitcode file is produced by a rather old clang, before they changed the meaning of the type argument to stores and loads, and currently fails with a "Invalid argument type on store" message.

More importantly, we have not yet provided semantics for the atomicrmw instruction. I believe the current situation is that we can load a BC file containing this instruction (provided it's build with a reasonably recent LLVM), but translation will fail if we actually try to execute a function containing the instruction.

@langston-barrett
Copy link
Contributor

That's my understanding as well. It's a very recent PR that implemented this in the parser: GaloisInc/llvm-pretty-bc-parser#111

@atomb
Copy link
Contributor

atomb commented Apr 2, 2019

With the latest parser, it's possible to load the module, but the translation to Crucible fails.

sawscript> m <- llvm_load_module "rustls.bc"
saw: Failure encountered while generating a Crucible CFG: at :370:0: Invalid argument type on store Typed {typedType = PtrTo (Alias (Ident "str_slice")), typedValue = ValIdent (Ident "_0")}

@atomb
Copy link
Contributor

atomb commented Apr 12, 2019

Even if the error produced above is inevitable (i.e., a well-typed Crucible program can't feasibly be generated), it might be nice to delay the error until runtime, so that it'll only get in the way if we try to symbolically execute the function in question.

@atomb atomb removed their assignment Apr 12, 2019
@robdockins
Copy link
Contributor

I believe that there are now translations for the atomicrmw instructions, so it seems like we just have to navigate the type question. If we produce a bitcode file with more recent rust/clang, this might just work...

@robdockins
Copy link
Contributor

I've attempted to reproduce this error by building rustls and loading it... however, recent rustc is based on LLVM version 8.0, which our bitcode parser cannot yet handle.

So, we seem to be blocked on GaloisInc/llvm-pretty-bc-parser#127

@atomb atomb added the maybe fixed Issues where there's reason to think they might be fixed but that still requires confirmation label May 21, 2019
@atomb atomb modified the milestones: 0.3, 1.0 May 21, 2019
@ctz
Copy link
Author

ctz commented Jul 4, 2019

I've attempted to reproduce this error by building rustls and loading it... however, recent rustc is based on LLVM version 8.0, which our bitcode parser cannot yet handle.

I've just come back to looking at this and am finding the same thing :( Worse, the last rustc which used LLVM 7 (1.29.2) does not support the 2018 edition of rust.

@atomb
Copy link
Contributor

atomb commented Oct 2, 2019

We now support the atomicrmw instruction and LLVM 8 and 9 (and therefore the output of the latest Rust compiler). For the store type error listed above, I think it's an instance of GaloisInc/llvm-pretty-bc-parser#135 (even though that specific example is about vector instructions --- I think the overall problem is broader). So I'm going to close this issue now.

@atomb atomb closed this as completed Oct 2, 2019
@ctz
Copy link
Author

ctz commented Dec 22, 2019

Took me a while to get back to this, but I'm pleased to say that I just tried this again with 0.4 and it worked fine. Thanks!

@sauclovian-g sauclovian-g removed the maybe fixed Issues where there's reason to think they might be fixed but that still requires confirmation label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Issues describing an improvement to an existing feature or capability
Projects
None yet
Development

No branches or pull requests

5 participants