-
Notifications
You must be signed in to change notification settings - Fork 25
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 unreachable instruction #11
Comments
This means that LLVM doesn't think the instruction should be reachable, based on LLVM's own semantics; but Haybale was able to reach it. That's unexpected, as Haybale is more-or-less intended to provide exactly LLVM's semantics. I think it's safe to assume that any LLVM code generated by a production compiler (
|
Thanks for your response! I will look into this some more and see if I can figure out which of these causes is responsible. |
I dug into one of the examples where I was hitting this issue. here is the function being executed ( #[derive(Copy, Clone, Debug)]
pub enum Clock {
HSB(HSBClock),
PBA(PBAClock),
PBB(PBBClock),
PBC(PBCClock),
PBD(PBDClock),
}
impl ClockInterface for Clock {
fn disable(&self) {
match self {
&Clock::HSB(v) => mask_clock!(HSB_MASK_OFFSET: hsbmask & !(1 << (v as u32))),
&Clock::PBA(v) => mask_clock!(PBA_MASK_OFFSET: pbamask & !(1 << (v as u32))),
&Clock::PBB(v) => mask_clock!(PBB_MASK_OFFSET: pbbmask & !(1 << (v as u32))),
&Clock::PBC(v) => mask_clock!(PBC_MASK_OFFSET: pbcmask & !(1 << (v as u32))),
&Clock::PBD(v) => mask_clock!(PBD_MASK_OFFSET: pbdmask & !(1 << (v as u32))),
}
}
} And here is the LLVM IR generated for that function:
Haybale is reaching the "unreachable" in basic block 5. As you can see, LLVM seems to be using basic block 5 as the default label for the switch statement, as it should be impossible for the input integer (%4) to be anything other 0-4 based on the definition of the enum. However, Haybale is apparently unaware of this constraint on the input integer, and thus considering bb %5 as a reachable path. Notably, I have not tried executing Haybale on just this function, I am reaching it as part of a larger execution (not sure if that matters). Any thoughts on why this might be happening? |
I tried just executing this method directly and get the same result |
There is nothing in the LLVM IR (other than the This seems to be a compelling example to motivate squashing the It seems much simpler to me to leave this outside of the scope of Haybale. Haybale iterates over all the paths in the LLVM IR, which includes this one; and it's up to Haybale's caller to decide what to do with each path. Callers are free to do anything they want with paths that end in errors, based on the particular error type or any other information they might know. In your case, I might recommend that your calling code just ignore paths that resulted in |
Thanks, this makes a lot of sense. I will try to take a look at a couple more examples to confirm this generalizes, then go forward with ignoring those paths. |
Ignoring these paths has been sufficient for my purposes, thanks for the guidance |
While symbolically executing a function, Haybale threw the following error:
Should I interpret this to mean the code under analysis is somehow invalid?
The text was updated successfully, but these errors were encountered: