Skip to content

Commit 1543488

Browse files
committed
Undo changes in isSafeToMove. Save for later PR
Signed-off-by: John Lu <[email protected]>
1 parent 5480713 commit 1543488

File tree

2 files changed

+4062
-5
lines changed

2 files changed

+4062
-5
lines changed

llvm/lib/Transforms/Scalar/Sink.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,34 @@ static bool hasStoreConflict(Instruction *Inst, AliasAnalysis &AA,
4444

4545
static bool isSafeToMove(Instruction *Inst, AliasAnalysis &AA,
4646
SmallPtrSetImpl<Instruction *> &Stores) {
47+
4748
if (Inst->mayWriteToMemory()) {
4849
Stores.insert(Inst);
4950
return false;
5051
}
52+
53+
if (LoadInst *L = dyn_cast<LoadInst>(Inst)) {
54+
MemoryLocation Loc = MemoryLocation::get(L);
55+
for (Instruction *S : Stores)
56+
if (isModSet(AA.getModRefInfo(S, Loc)))
57+
return false;
58+
}
59+
5160
if (Inst->isTerminator() || isa<PHINode>(Inst) || Inst->isEHPad() ||
5261
Inst->mayThrow() || !Inst->willReturn())
5362
return false;
54-
// Convergent operations cannot be made control-dependent on additional
55-
// values.
56-
if (auto *Call = dyn_cast<CallBase>(Inst))
63+
64+
if (auto *Call = dyn_cast<CallBase>(Inst)) {
65+
// Convergent operations cannot be made control-dependent on additional
66+
// values.
5767
if (Call->isConvergent())
5868
return false;
59-
if (hasStoreConflict(Inst, AA, Stores))
60-
return false;
69+
70+
for (Instruction *S : Stores)
71+
if (isModSet(AA.getModRefInfo(S, Call)))
72+
return false;
73+
}
74+
6175
return true;
6276
}
6377

0 commit comments

Comments
 (0)