[LLVMdev] Transforming ConstantExprs to Instructions
Chris Lattner
sabre at nondot.org
Thu Jun 19 09:58:52 PDT 2008
On Thu, 19 Jun 2008, Eli Friedman wrote:
> 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".
Ah, I see. Right, you'd need to change the constexprs into instructions.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list