summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-09-20 16:45:58 +0000
committerDuncan Sands <baldrick@free.fr>2008-09-20 16:45:58 +0000
commite1dc84be64b8b8d88451d60b2d3ff7ef8ebe74a0 (patch)
tree37d72a7adf98475bb5e7ae486aa415c0d222b5fd /llvm/lib/Transforms
parentde195e2100fb53cc644b5e5600a9299893297123 (diff)
downloadbcm5719-llvm-e1dc84be64b8b8d88451d60b2d3ff7ef8ebe74a0.tar.gz
bcm5719-llvm-e1dc84be64b8b8d88451d60b2d3ff7ef8ebe74a0.zip
Implement review feedback from Devang: make use
of mayReadFromMemory and mayWriteToMemory. llvm-svn: 56387
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/AddReadAttrs.cpp37
1 files changed, 11 insertions, 26 deletions
diff --git a/llvm/lib/Transforms/IPO/AddReadAttrs.cpp b/llvm/lib/Transforms/IPO/AddReadAttrs.cpp
index 1052e06b72f..8f7fd6e6a8c 100644
--- a/llvm/lib/Transforms/IPO/AddReadAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/AddReadAttrs.cpp
@@ -54,7 +54,7 @@ bool AddReadAttrs::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
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 @@ bool AddReadAttrs::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
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);
-
- if (std::find(SCC.begin(), SCC.end(), CG[CS.getCalledFunction()]) !=
- SCC.end())
- // The callee is inside our current SCC - ignore it.
- continue;
+ CallSite CS = CallSite::get(&*II);
- if (!CS.onlyReadsMemory())
- // May write memory.
- return false;
+ // Ignore calls to functions in the same SCC.
+ if (CS.getInstruction() &&
+ std::find(SCC.begin(), SCC.end(), CG[CS.getCalledFunction()]) !=
+ SCC.end())
+ continue;
- if (!CS.doesNotAccessMemory())
- ReadsMemory = true;
- }
+ if (II->mayWriteToMemory())
+ return false;
+ ReadsMemory |= II->mayReadFromMemory();
}
}
OpenPOWER on IntegriCloud