diff options
| -rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 65faef32e5e..e8315247b23 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -152,6 +152,11 @@ bool FunctionAttrs::AddReadAttrs(const std::vector<CallGraphNode *> &SCC) { 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(); } diff --git a/llvm/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll b/llvm/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll new file mode 100644 index 00000000000..4022033c3b0 --- /dev/null +++ b/llvm/test/Transforms/FunctionAttrs/2009-05-06-Malloc.ll @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | not grep read +; PR3754 + +define i8* @m(i32 %size) { + %tmp = malloc i8, i32 %size ; <i8*> [#uses=1] + ret i8* %tmp +} |

