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

Match against LLVMValString in overrides (#2148) #2149

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

RyanGlScott
Copy link
Contributor

LLVM will sometimes optimize uint8_t arrays into top-level string constants. For example, Clang will optimize uint8_t xs[4] = {0,1,2,3}; into the LLVM string constant "\00\01\02\03". This is still a value of type [4 x i8], but it uses string syntax for convenience. crucible-llvm mirrors this choice by having a dedicated LLVMValString value alongside the more general LLVMValArray, with the former using a ByteString as its payload for convenience.

While SAW's LLVM override matching logic had cases for LLVMValArray, it did not have cases for LLVMValString, which meant that any override that needs to match on an LLVM string constant argument would fail. This is easily fixed by adding the missing cases.

Fixes #2148.

LLVM will sometimes optimize `uint8_t` arrays into top-level string constants.
For example, Clang will optimize `uint8_t xs[4] = {0,1,2,3};` into the LLVM
string constant `"\00\01\02\03"`. This is still a value of type `[4 x i8]`, but
it uses string syntax for convenience. `crucible-llvm` mirrors this choice by
having a dedicated `LLVMValString` value alongside the more general
`LLVMValArray`, with the former using a `ByteString` as its payload for
convenience.

While SAW's LLVM override matching logic had cases for `LLVMValArray`, it did
_not_ have cases for `LLVMValString`, which meant that any override that needs
to match on an LLVM string constant argument would fail. This is easily fixed
by adding the missing cases.

Fixes #2148.
@RyanGlScott RyanGlScott merged commit 73ef5b2 into master Nov 11, 2024
34 checks passed
@RyanGlScott RyanGlScott deleted the T2148-match-LLVMValString branch November 11, 2024 23:34
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.

SAW fails to match LLVM override involving top-level string constants
2 participants