summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-09-18 19:20:02 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-09-18 19:20:02 +0000
commit788eaabd18ea11dec935dd82fc21d6388b86e291 (patch)
tree1a1bd5b8185f1250ee409ef5152ba1dd9fabdc9a /llvm/lib/VMCore/Verifier.cpp
parent327c8df90c2c341f52818d2f13aaf5ac1ac6f76b (diff)
downloadbcm5719-llvm-788eaabd18ea11dec935dd82fc21d6388b86e291.tar.gz
bcm5719-llvm-788eaabd18ea11dec935dd82fc21d6388b86e291.zip
Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants. Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array. Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type. Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls. Add verification for malloc calls. Reviewed by Dan Gohman. llvm-svn: 82257
Diffstat (limited to 'llvm/lib/VMCore/Verifier.cpp')
-rw-r--r--llvm/lib/VMCore/Verifier.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 140e6bd8b15..f1f6e2e199b 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -1143,6 +1143,16 @@ void Verifier::visitCallInst(CallInst &CI) {
if (Function *F = CI.getCalledFunction())
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
visitIntrinsicFunctionCall(ID, CI);
+
+ // Code here matches isMalloc from MallocHelper, which is not in VMCore.
+ 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);
+ }
}
void Verifier::visitInvokeInst(InvokeInst &II) {
OpenPOWER on IntegriCloud