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

Duncan Sands baldrick at free.fr
Tue Sep 22 06:11:18 PDT 2009

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 =
     Assert1(CI.getType() == PTy, "Malloc call must return i8*", &CI);

I think it is completely wrong for the verifier to be checking anything
about calls to functions that happen to be called "malloc".  What if I
have my own runtime in which "malloc" is completely different to the
usual one?  From my reading of the gcc docs, malloc is not provided
in a freestanding environment and thus cannot be assumed to be the
normal malloc.

I think this code should be removed from the verifier.  Instead,
isMalloc should also check the number of parameters and their types,
as well as the return value.

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



More information about the llvm-dev mailing list