[LLVMdev] FYI: AllocaInst & MallocInst ctor change

Chris Lattner sabre at nondot.org
Fri Sep 13 17:55:01 PDT 2002


Just a note:  I just checked in a change that corrects some very
non-intuitive behavior of the AllocaInst & MallocInst classes.  Before,
the constructor would take a Type which would specify the return type of
the instruction, instead of the operand type.  Now it takes the operand
type directly.  More concretely:

LLVM Code:
X = alloca int        ; int*
Y = malloc int *      ; int**

Old C++ code:
X = new AllocaInst(PointerType::get(Type::IntTy));
Y = new MallocInst(PointerType::get(PointerType::get(Type::IntTy)));
assert(X->getType() == PointerType::get(Type::IntTy));

New C++ code:
X = new AllocaInst(Type::IntTy);
Y = new MallocInst(PointerType::get(Type::IntTy));
assert(X->getType() == PointerType::get(Type::IntTy));

The old behavior was quite confusing for some people I talked to, and the
assertion failure message apparently didn't help much.  I expect that this
change will meet people's expectations better.

Unfortunately, any code that calls one of these constructors will have to
change.  I updated the mainline transformations, but anything not in our
CVS tree will break (including the 426 students projects, when the CSIL
CVS tree is updated).

-Chris

http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list