Don't let globalopt hack on volatile loads or stores.

llvm-svn: 46523
This commit is contained in:
Chris Lattner 2008-01-29 19:01:37 +00:00
parent acc17d1b24
commit e08ec140e0
2 changed files with 13 additions and 1 deletions

View File

@ -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.

View File

@ -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
}