Malloc/Free have mod/ref effects. Do not allow CSE of function calls that
authorChris Lattner <sabre@nondot.org>
Fri, 22 Apr 2005 05:36:59 +0000 (05:36 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 22 Apr 2005 05:36:59 +0000 (05:36 +0000)
call malloc/free.  This fixes PR555.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21443 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/IPA/GlobalsModRef.cpp

index 20422bf3189c402b3a470ec06bf5814f4ba50fc4..5b3c953bcdfa25925dc078aa94a5bcd11fd1bc83 100644 (file)
@@ -310,6 +310,8 @@ void GlobalsModRef::AnalyzeSCC(std::vector<CallGraphNode *> &SCC) {
           FunctionEffect |= Ref;
         else if (isa<StoreInst>(*II))
           FunctionEffect |= Mod;
+        else if (isa<MallocInst>(*II) || isa<FreeInst>(*II))
+          FunctionEffect |= ModRef;
   }
 
   if ((FunctionEffect & Mod) == 0)