[llvm-commits] [llvm] r56387 - /llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp
Duncan Sands
baldrick at free.fr
Sat Sep 20 09:45:59 PDT 2008
Author: baldrick
Date: Sat Sep 20 11:45:58 2008
New Revision: 56387
URL: http://llvm.org/viewvc/llvm-project?rev=56387&view=rev
Log:
Implement review feedback from Devang: make use
of mayReadFromMemory and mayWriteToMemory.
Modified:
llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp
Modified: llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp?rev=56387&r1=56386&r2=56387&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/AddReadAttrs.cpp Sat Sep 20 11:45:58 2008
@@ -54,7 +54,7 @@
Function *F = SCC[i]->getFunction();
if (F == 0)
- // May write memory.
+ // External node - may write memory.
return false;
if (F->doesNotAccessMemory())
@@ -72,34 +72,19 @@
continue;
}
- // Scan the function body for explicit loads and stores, or calls to
- // functions that may read or write memory.
+ // Scan the function body for instructions that may read or write memory.
for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) {
- Instruction *I = &*II;
- if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
- if (LI->isVolatile())
- // Volatile loads may have side-effects, so treat them as writing
- // memory.
- return false;
- ReadsMemory = true;
- } else if (isa<StoreInst>(I) || isa<MallocInst>(I) || isa<FreeInst>(I)) {
- // Writes memory.
- return false;
- } else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
- CallSite CS(I);
+ CallSite CS = CallSite::get(&*II);
+
+ // Ignore calls to functions in the same SCC.
+ if (CS.getInstruction() &&
+ std::find(SCC.begin(), SCC.end(), CG[CS.getCalledFunction()]) !=
+ SCC.end())
+ continue;
- if (std::find(SCC.begin(), SCC.end(), CG[CS.getCalledFunction()]) !=
- SCC.end())
- // The callee is inside our current SCC - ignore it.
- continue;
-
- if (!CS.onlyReadsMemory())
- // May write memory.
- return false;
-
- if (!CS.doesNotAccessMemory())
- ReadsMemory = true;
- }
+ if (II->mayWriteToMemory())
+ return false;
+ ReadsMemory |= II->mayReadFromMemory();
}
}
More information about the llvm-commits
mailing list