I realized that Constant in LLVM is not the same as variable with c/c++'s const modifier.
Is there any way for me to differentiate C/C++ variables with const modifier in LLVM from those that do not have it? (all variables including globals)
I realized that Constant in LLVM is not the same as variable with c/c++'s const modifier.
Is there any way for me to differentiate C/C++ variables with const modifier in LLVM from those that do not have it? (all variables including globals)
LLVM IR isn't intended to represent the source type system, it's an intermediate representation and contains the type information that's useful for compiling, which will resemble the source types but need not capture all aspects. If you want the source type system, you have to look at the debug information, which need not be present, but if it is present it is at least intended to contain the data you want.
You can start looking at DIType. Be warned that this code isn't awfully well documented.
Global variables have a convenient method, though, isConstant().