[llvm-commits] [llvm] r56188 - in /llvm/trunk: lib/Analysis/IPA/GlobalsModRef.cpp test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll
Duncan Sands
baldrick at free.fr
Sat Sep 13 05:45:50 PDT 2008
Author: baldrick
Date: Sat Sep 13 07:45:50 2008
New Revision: 56188
URL: http://llvm.org/viewvc/llvm-project?rev=56188&view=rev
Log:
Fix PR2792: treat volatile loads as writing memory somewhere.
Treat stores as reading memory, just to play safe.
Added:
llvm/trunk/test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll
Modified:
llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp
Modified: llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp?rev=56188&r1=56187&r2=56188&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp Sat Sep 13 07:45:50 2008
@@ -431,12 +431,20 @@
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;
Added: llvm/trunk/test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll?rev=56188&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll (added)
+++ llvm/trunk/test/Analysis/GlobalsModRef/2008-09-13-VolatileRead.ll Sat Sep 13 07:45:50 2008
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -globalsmodref-aa -markmodref | llvm-dis | not grep read
+; PR2792
+
+ at g = global i32 0 ; <i32*> [#uses=1]
+
+define i32 @f() {
+ %t = volatile load i32* @g ; <i32> [#uses=1]
+ ret i32 %t
+}
More information about the llvm-commits
mailing list