Fix PR3754: don't mark functions that wrap MallocInst with
the readnone. Since MallocInst is scheduled for deletion
it doesn't seem worth doing anything more subtle, such as
having mayWriteToMemory return true for MallocInst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71077 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index 65faef3..e831524 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -152,6 +152,11 @@
if (I->mayWriteToMemory())
// Writes memory. Just give up.
return false;
+
+ if (isa<MallocInst>(I))
+ // MallocInst claims not to write memory! PR3754.
+ return false;
+
// If this instruction may read memory, remember that.
ReadsMemory |= I->mayReadFromMemory();
}