mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Fix an issue with the IR sink pass found by inspection. (I'm not sure anyone is actually using this, but might as well fix it since I found the issue.)
llvm-svn: 138965
This commit is contained in:
parent
a154929048
commit
00a62b2122
@ -153,9 +153,13 @@ bool Sinking::ProcessBlock(BasicBlock &BB) {
|
||||
|
||||
static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
|
||||
SmallPtrSet<Instruction *, 8> &Stores) {
|
||||
if (LoadInst *L = dyn_cast<LoadInst>(Inst)) {
|
||||
if (L->isVolatile()) return false;
|
||||
|
||||
if (Inst->mayWriteToMemory()) {
|
||||
Stores.insert(Inst);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LoadInst *L = dyn_cast<LoadInst>(Inst)) {
|
||||
AliasAnalysis::Location Loc = AA->getLocation(L);
|
||||
for (SmallPtrSet<Instruction *, 8>::iterator I = Stores.begin(),
|
||||
E = Stores.end(); I != E; ++I)
|
||||
@ -163,11 +167,6 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Inst->mayWriteToMemory()) {
|
||||
Stores.insert(Inst);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst))
|
||||
return false;
|
||||
|
||||
|
@ -20,3 +20,19 @@ true:
|
||||
false:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; But don't sink volatile loads...
|
||||
|
||||
; CHECK: @foo2
|
||||
; CHECK: volatile load
|
||||
; CHECK-NEXT: store i32
|
||||
|
||||
define i32 @foo2(i1 %z) {
|
||||
%l = volatile load i32* @A
|
||||
store i32 0, i32* @B
|
||||
br i1 %z, label %true, label %false
|
||||
true:
|
||||
ret i32 %l
|
||||
false:
|
||||
ret i32 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user