summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-04-25 19:44:25 +0000
committerMatthias Braun <matze@braunis.de>2017-04-25 19:44:25 +0000
commitc36a78c3f338f7f4da1db1074211dd748c833675 (patch)
tree71796b07737d646ffc1bb407751035426b306020 /llvm/lib/Transforms/Utils
parentdd21502482a5ab56aa104f572320dff16cae990c (diff)
downloadbcm5719-llvm-c36a78c3f338f7f4da1db1074211dd748c833675.tar.gz
bcm5719-llvm-c36a78c3f338f7f4da1db1074211dd748c833675.zip
SimplifyLibCalls: Fix crash on memset(notmalloc())
rdar://31520787 llvm-svn: 301352
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 4818939824e..2640c1f447a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -842,6 +842,9 @@ static Value *foldMallocMemset(CallInst *Memset, IRBuilder<> &B,
// Is the inner call really malloc()?
Function *InnerCallee = Malloc->getCalledFunction();
+ if (!InnerCallee)
+ return nullptr;
+
LibFunc Func;
if (!TLI.getLibFunc(*InnerCallee, Func) || !TLI.has(Func) ||
Func != LibFunc_malloc)
OpenPOWER on IntegriCloud