[LLVMdev] Verifier should not make any assumptions about calls to "malloc"

Chris Lattner clattner at apple.com
Tue Sep 22 10:11:12 PDT 2009


On Sep 22, 2009, at 6:11 AM, Duncan Sands wrote:

> Hi Victor, this code from the verifier broke the Ada front-end build:
>
>   const Module* M = CI.getParent()->getParent()->getParent();
>   Constant *MallocFunc = M->getFunction("malloc");
>
>   if (CI.getOperand(0) == MallocFunc) {
>     const PointerType *PTy =
>
> PointerType::getUnqual(Type::getInt8Ty(CI.getParent()->getContext()));
>     Assert1(CI.getType() == PTy, "Malloc call must return i8*", &CI);
>   }

Yes, I agree, the verifier shouldn't worry about malloc calls.

> Actually isMalloc also seems bogus.  In a freestanding environment
> there is no reason that a function that happens to be called "malloc"
> should have anything to do with memory allocation.  Do you have a
> plan to handle this?  Shouldn't all malloc manipulations be done from
> SimplifyLibcalls?

We violate this in other places. If someone is worried about  
freestanding environments and -fno-builtin-malloc, we should add a new  
function attribute "not builtin" and have the optimizer respect that.

-Chris



More information about the llvm-dev mailing list