[LLVMdev] replacing a global variable by a constant
Ralf Karrenberg
Chareos at gmx.de
Fri Dec 5 06:05:48 PST 2008
Hi,
I am trying to replace a global variable with a constant.
I did manage to do it, but somehow it appears to be fairly bruteforce by
just iterating over all functions/bblocks/instructions and filtering for
those that load the variable and replacing the instruction with
Instruction::replaceAllUsesWith().
The more intuitive way of iterating over the uses of the variable did
not work out as I have to replace the whole instruction instead of just
the operand (as GlobalVariable::replaceAllUsesWith() does) in order to
prevent loading from the memory address of the constant instead of
loading the constant :p. Basically what seems to be missing is some
method that returns the parent-instruction of a Use.
Maybe I am even tackling the whole problem from the wrong side anyway?!
And another question:
Does an invokation of a JIT through runFunction() perform any
optimization(s) by itself? Is there a way to display the generated code?
Thank you in advance :).
Regards,
Ralf
More information about the llvm-dev
mailing list