[llvm-commits] [llvm] r56948 - in /llvm/trunk: lib/CodeGen/MachineInstr.cpp test/CodeGen/X86/volatile.ll

Dan Gohman gohman at apple.com
Thu Oct 2 08:04:32 PDT 2008


Author: djg
Date: Thu Oct  2 10:04:30 2008
New Revision: 56948

URL: http://llvm.org/viewvc/llvm-project?rev=56948&view=rev
Log:
Fix a think-o in isSafeToMove. This fixes it from thinking that
volatile memory references are safe to move.

Added:
    llvm/trunk/test/CodeGen/X86/volatile.ll
Modified:
    llvm/trunk/lib/CodeGen/MachineInstr.cpp

Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=56948&r1=56947&r2=56948&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Thu Oct  2 10:04:30 2008
@@ -707,7 +707,7 @@
   if (TID->mayLoad() && !TII->isInvariantLoad(this))
     // Otherwise, this is a real load.  If there is a store between the load and
     // end of block, or if the laod is volatile, we can't move it.
-    return SawStore || hasVolatileMemoryRef();
+    return !SawStore && !hasVolatileMemoryRef();
 
   return true;
 }

Added: llvm/trunk/test/CodeGen/X86/volatile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/volatile.ll?rev=56948&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/volatile.ll (added)
+++ llvm/trunk/test/CodeGen/X86/volatile.ll Thu Oct  2 10:04:30 2008
@@ -0,0 +1,17 @@
+; RUN: llvm-as < %s | llc -march=x86 -mattr=sse2 | grep movsd | count 5
+; RUN: llvm-as < %s | llc -march=x86 -mattr=sse2 -fast | grep movsd | count 5
+
+ at x = external global double
+
+define void @foo() nounwind  {
+  %a = volatile load double* @x
+  volatile store double 0.0, double* @x
+  volatile store double 0.0, double* @x
+  %b = volatile load double* @x
+  ret void
+}
+
+define void @bar() nounwind  {
+  %c = volatile load double* @x
+  ret void
+}





More information about the llvm-commits mailing list