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

Work around LLVM's reltable lookup optimization #1214

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

RyanGlScott
Copy link
Contributor

Clang 14.0.0+ introduce a relative lookup table optimization that produces code that subtracts two pointers from different allocation regions, which is something that crucible-llvm is ill equipped to reason about. For lack of a viable alternative, we work around this issue by "undoing" this optimization before translating the code to Crucible. For the full details, see the new Note [Undoing LLVM's relative table lookup conversion pass] in Lang.Crucible.LLVM.Globals.

Fixes #1174.

Clang 14.0.0+ introduce a relative lookup table optimization that produces code
that subtracts two pointers from different allocation regions, which is
something that `crucible-llvm` is ill equipped to reason about. For lack of a
viable alternative, we work around this issue by "undoing" this optimization
before translating the code to Crucible. For the full details, see the new
`Note [Undoing LLVM's relative table lookup conversion pass]` in
`Lang.Crucible.LLVM.Globals`.

Fixes #1174.
Copy link
Member

@kquick kquick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of very specific pattern recognition in buildLoadRelConstInitMap, which is good because it limits the functionality to a very specific case and prevents capturing unrelated scenarios, but for the same reasons this is also very brittle and I feel like we haven't seen the last of this. Nonetheless, I agree that this seems like the best way I can think of to handle this LLVM shortcut.

@RyanGlScott RyanGlScott merged commit f9760bd into master Jun 11, 2024
32 checks passed
@RyanGlScott RyanGlScott deleted the T1174-undo-reltable-optimization branch June 11, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crucible-llvm: Support string tables with Clang 14.0.0 + optimizations
3 participants