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

Implement CST_CODE_CE_GEP (replacing CST_CODE_CE_GEP_OLD in LLVM 19) #278

Open
RyanGlScott opened this issue Sep 25, 2024 · 0 comments
Open

Comments

@RyanGlScott
Copy link
Contributor

LLVM 19 adds the ability to nusw and nuw flags to constant getelementptr expressions. As a result, there is now a new CST_CODE_CE_GEP (constant code 32), which replaces what is now known as CST_CODE_CE_GEP_OLD (constant code 12). This was implemented on the LLVM side in commit llvm/llvm-project@8cdecd4.

We will need to implement support for this on the llvm-pretty-bc-parser side. A minimal example that currently fails:

%struct.RT = type { i8, [10 x [20 x i32]], i8 }
%struct.ST = type { i32, double, %struct.RT }

@.s = private constant %struct.ST zeroinitializer

define ptr @foo() {
entry:
  ret ptr getelementptr inbounds (%struct.ST, ptr @.s, i64 1, i32 2, i32 1, i64 5, i64 13)
}

If you compile this to bitcode using llvm-as-19.1.0 and attempt to parse the resulting bitcode, it will fail with:

λ> parseBitCodeFromFile "test.bc"
Left (Error {errContext = ["CONSTANTS_BLOCK","@foo","FUNCTION_BLOCK","FUNCTION_BLOCK_ID","value symbol table","MODULE_BLOCK","Bitstream"], errMessage = "Unknown constant record code 32\nAre you sure you're using a supported compiler?\nCheck here: https://github.com/GaloisInc/llvm-pretty-bc-parser\n"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant