Author: lattner
Date: Tue Jan 29 13:01:37 2008
New Revision: 46523

URL: http://llvm.org/viewvc/llvm-project?rev=46523&view=rev
Log:
Don't let globalopt hack on volatile loads or stores.

Added:
    llvm/trunk/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=46523&r1=46522&r2=46523&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Jan 29 13:01:37 2008
@@ -163,12 +163,15 @@
         else if (GS.AccessingFunction != F)
           GS.HasMultipleAccessingFunctions = true;
       }
-      if (isa<LoadInst>(I)) {
+      if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
         GS.isLoaded = true;
+        if (LI->isVolatile()) return true;  // Don't hack on volatile loads.
       } else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
         // Don't allow a store OF the address, only stores TO the address.
         if (SI->getOperand(0) == V) return true;
 
+        if (SI->isVolatile()) return true;  // Don't hack on volatile stores.
+
         // If this is a direct store to the global (i.e., the global is a 
scalar
         // value, not an aggregate), keep more specific information about
         // stores.

Added: llvm/trunk/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll?rev=46523&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll (added)
+++ llvm/trunk/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll Tue Jan 
29 13:01:37 2008
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -globalopt | llvm-dis | grep {volatile load}
[EMAIL PROTECTED] = internal global double 0x3FD5555555555555, align 8          
; <double*> [#uses=1]
+
+define double @foo() nounwind  {
+entry:
+       %tmp1 = volatile load double* @t0.1441, align 8         ; <double> 
[#uses=2]
+       %tmp4 = mul double %tmp1, %tmp1         ; <double> [#uses=1]
+       ret double %tmp4
+}


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to