Matthijs Kooijman
2008-Jun-18 08:36 UTC
[LLVMdev] Transforming ConstantExprs to Instructions
Hi Chris,> > [ Snip replacing constantexprs with instructions ] > Ok, this is not possible in general though, global variable initializers > have to be constants, not instructions.Yeah, so if not all uses can be replaced, my pass will just have to skip the variable.> Is it possible to design the pass to work with both? The general approach > is to make stuff handle "User"s instead of Instructions. It is much more > compile time efficient to just handle the two forms rather than converting > them back and forth.With both I assume you mean both GEP instrs and GEP constantexprs? If so then yes, I am intending to make it work with both, and that's exactly why I need to convert the constantexprs to instructions (Since, unless I'm very much mistaken, a gepconstantexpr won't work with an alloca, so I can't leave them intact). Gr. Matthijs -------------- 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/20080618/9efea1a7/attachment.sig>
On Jun 18, 2008, at 1:36 AM, Matthijs Kooijman wrote:>> Is it possible to design the pass to work with both? The general >> approach >> is to make stuff handle "User"s instead of Instructions. It is >> much more >> compile time efficient to just handle the two forms rather than >> converting >> them back and forth. > With both I assume you mean both GEP instrs and GEP constantexprs? > If so then > yes, I am intending to make it work with both, and that's exactly > why I need > to convert the constantexprs to instructions (Since, unless I'm very > much > mistaken, a gepconstantexpr won't work with an alloca, so I can't > leave them > intact).What do you mean? A constantexpr gep can be used as the size of an alloca. -Chris
On Wed, Jun 18, 2008 at 10:19 PM, Chris Lattner <sabre at nondot.org> wrote:> What do you mean? A constantexpr gep can be used as the size of an > alloca.A constantexpr as an argument to an alloca is legal, but a constantexpr can't use an alloca. Suppose you have a global struct, and you load the third member. The IL for this is something like "load i32* getelementptr ( %struct @x, i32 0, i32 2)". Now you want to replace the global @x with a local alloca %x (assuming all the appropriate safety checks are done). "load i32* getelementptr (%struct %x, i32 0, i32 2)" is illegal; it has to be split into "%loadaddr = getelementptr %struct %x, i32 0, i32 2" and "load i32* %loadaddr". -Eli
Matthijs Kooijman
2008-Jun-19 08:05 UTC
[LLVMdev] Transforming ConstantExprs to Instructions
Hi Chris,> What do you mean? A constantexpr gep can be used as the size of an > alloca.I meant the other way around. Ie, @A = internal global { i32, i32 } %B = load getelementptr { i32, i32 }* @A, i32 0, i32 0 would trivially translate to %A = alloca { i32, i32 } %B = load getelementptr { i32, i32 }* %A, i32 0, i32 0 which is not legal AFAICS (since %A is not a Constant). Gr. Matthijs -------------- 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/20080619/fba33896/attachment.sig>
Apparently Analagous Threads
- [LLVMdev] Transforming ConstantExprs to Instructions
- [LLVMdev] Transforming ConstantExprs to Instructions
- [LLVMdev] Transforming ConstantExprs to Instructions
- [LLVMdev] Transforming ConstantExprs to Instructions
- [LLVMdev] question about enabling cfl-aa and collecting a57 numbers