[LLVMdev] Transforming ConstantExprs to Instructions

Matthijs Kooijman matthijs at stdin.nl
Tue Jun 17 08:50:51 PDT 2008


I've been struggling with constantexprs for a bit. I'm working on a pass that
transforms global variables to local variables, and in particular the
GetElementPtrConstantExpr is a bit troublesome. For my transformation to
properly work, a global value should only be used by Instructions, not by

I was thinking to add a ConstantExpr::replaceWithInstr() virtual method, which
translates all of the uses of a constantexpr with their Instruction
equivalents, whenever possible. Each of the subclasses of ConstantExpr can
implement this as appropriate. Or, thinking of it, it's probably better to
have a protected and virtual replaceUseWithInstr method which is called for
each use by replaceWithInstr().

Is this a useful addition? Is this a sane approach?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080617/abba518c/attachment.sig>

More information about the llvm-dev mailing list