-
Notifications
You must be signed in to change notification settings - Fork 41
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
: Support string tables with Clang 14.0.0 + optimizations
#1174
Comments
The code that throws this error is here: crucible/crucible-llvm/src/Lang/Crucible/LLVM/Translation/Constant.hs Lines 668 to 674 in 6d0af7c
In this case, the |
The LLVM documentation for the
In this case, a likely solution would be to:
In the example above, that would mean that |
Actually, the first bullet point in #1174 (comment) won't work. This is because the offsets for Indeed, this is much trickier than I originally thought. Under most circumstances, subtracting two pointers from different allocation blocks (as would be the case when subtracting two distinct global variables) is undefined behavior in C. As far as I can tell, the only reason that pointer subtraction works out in the code above is because LLVM's constant folder has a special case when the argument to Ugh. |
crucible-llvm
: Support C string tables with Clang 14.0.0 + optimizationscrucible-llvm
: Support string tables with Clang 14.0.0 + optimizations
This error can also arise with Rust compiled to LLVM bitcode: // test.rs
pub enum Table {
A,
B,
C,
}
pub fn f(t: Table) -> &'static str {
match t {
Table::A => "A",
Table::B => "B",
Table::C => "C",
}
}
#[no_mangle]
pub fn test() {}
|
This reltable optimization has also proved troublesome for CHERI: CTSRD-CHERI/llvm-project#572 |
Unfortunately, I really don't know how to make In light of this, perhaps we should do something akin to the following:
This is all very ugly, but I can't think of a better solution at present. |
Consider this code, which was minimized from a real-world example:
If you run this through
crux-llvm
with optimizations and Clang 14.0.0, it will crash:It will pass if:
The problematic bitcode in the Clang 14.0.0 + optimizations version is:
Without optimizations (or with Clang 12.0.0), we instead have:
The text was updated successfully, but these errors were encountered: