[LLVMdev] safe to speculatively execute load of malloc?

Jay Foad jay.foad at gmail.com
Sun Jan 3 04:54:23 PST 2010

I've just noticed this, in Instruction::isSafeToSpeculativelyExecute():


00430   case Load: {
00431     if (cast<LoadInst>(this)->isVolatile())
00432       return false;
00433     if (isa<AllocaInst>(getOperand(0)) || isMalloc(getOperand(0)))
00434       return true;

This says that it's safe to speculatively execute a load from the
pointer returned by malloc(). But surely that's not true if malloc()
returns NULL.


More information about the llvm-dev mailing list