2

How can I get all the variables (from bytecode file or IR file) with const modifier or the variables that are not changed due execution? I need to make list for further use.

2
  • There are no variables in LLVM IR, do you mean variables in the source code, assuming it is C or C++? Or do you mean LLVM IR globals? Commented Nov 27, 2013 at 7:43
  • I mean variables in C or C++ code. How can I get elements? (llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantDataArray, ConstantExpr and etc) Commented Nov 27, 2013 at 9:20

1 Answer 1

1

I'm not sure you can get what you want directly because const is a C/C++ semantic that's useful for Clang but much less so for LLVM. Only some const promises are preserved (for example the readonly attribute on pointer function arguments - see the language reference for details).

LLVM IR level "constants" are something entirely different, and usually refer to actually constant (compile-time known) values that can be efficiently uniqued, etc. Read this documentation for the full scoop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.