diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-29 19:01:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-29 19:01:37 +0000 |
commit | 75a2db813395e577d844d0996b4528010ee09e1d (patch) | |
tree | caa11d95db7518da145c405ec09b9f541d510827 | |
parent | 58401bbcc01606be38e90387ad4c9f23ab021604 (diff) | |
download | external_llvm-75a2db813395e577d844d0996b4528010ee09e1d.zip external_llvm-75a2db813395e577d844d0996b4528010ee09e1d.tar.gz external_llvm-75a2db813395e577d844d0996b4528010ee09e1d.tar.bz2 |
Don't let globalopt hack on volatile loads or stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46523 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 5 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index ea8080e..7bed9e2 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -163,12 +163,15 @@ static bool AnalyzeGlobal(Value *V, GlobalStatus &GS, 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. diff --git a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll new file mode 100644 index 0000000..0a8dd49 --- /dev/null +++ b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | opt -globalopt | llvm-dis | grep {volatile load} +@t0.1441 = 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 +} |