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.
-
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?Oak– Oak2013-11-27 07:43:25 +00:00Commented 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)Denis– Denis2013-11-27 09:20:20 +00:00Commented Nov 27, 2013 at 9:20
Add a comment
|
1 Answer
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.