aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/IPA
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-09-13 12:45:50 +0000
committerDuncan Sands <baldrick@free.fr>2008-09-13 12:45:50 +0000
commit131357271f3824981b1d0572685fbc380983aa35 (patch)
tree465c96bbb30ed24cef5f2e406f3a71e348b47148 /lib/Analysis/IPA
parent453bbc3a0040eb095c89c4e5c055d7333eb865f3 (diff)
downloadexternal_llvm-131357271f3824981b1d0572685fbc380983aa35.zip
external_llvm-131357271f3824981b1d0572685fbc380983aa35.tar.gz
external_llvm-131357271f3824981b1d0572685fbc380983aa35.tar.bz2
Fix PR2792: treat volatile loads as writing memory somewhere.
Treat stores as reading memory, just to play safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA')
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp
index 390a602..74327d5 100644
--- a/lib/Analysis/IPA/GlobalsModRef.cpp
+++ b/lib/Analysis/IPA/GlobalsModRef.cpp
@@ -431,12 +431,20 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
for (inst_iterator II = inst_begin(SCC[i]->getFunction()),
E = inst_end(SCC[i]->getFunction());
II != E && FunctionEffect != ModRef; ++II)
- if (isa<LoadInst>(*II))
+ if (isa<LoadInst>(*II)) {
FunctionEffect |= Ref;
- else if (isa<StoreInst>(*II))
+ if (cast<LoadInst>(*II).isVolatile())
+ // Volatile loads may have side-effects, so mark them as writing
+ // memory (for example, a flag inside the processor).
+ FunctionEffect |= Mod;
+ } else if (isa<StoreInst>(*II)) {
FunctionEffect |= Mod;
- else if (isa<MallocInst>(*II) || isa<FreeInst>(*II))
+ if (cast<StoreInst>(*II).isVolatile())
+ // Treat volatile stores as reading memory somewhere.
+ FunctionEffect |= Ref;
+ } else if (isa<MallocInst>(*II) || isa<FreeInst>(*II)) {
FunctionEffect |= ModRef;
+ }
if ((FunctionEffect & Mod) == 0)
++NumReadMemFunctions;