Skip to content

Commit 571e024

Browse files
authored
[Sink][NFC] Move all checks for unsafe instructions into one function (llvm#137398)
Move check for instruction that is unsafe to sink into isSafeToMove function. Signed-off-by: John Lu <[email protected]>
1 parent e6f7e34 commit 571e024

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Transforms/Scalar/Sink.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis &AA,
3535
return false;
3636
}
3737

38+
// Don't sink static alloca instructions. CodeGen assumes allocas outside the
39+
// entry block are dynamically sized stack objects.
40+
if (AllocaInst *AI = dyn_cast<AllocaInst>(Inst))
41+
if (AI->isStaticAlloca())
42+
return false;
43+
3844
if (LoadInst *L = dyn_cast<LoadInst>(Inst)) {
3945
MemoryLocation Loc = MemoryLocation::get(L);
4046
for (Instruction *S : Stores)
@@ -98,12 +104,6 @@ static bool SinkInstruction(Instruction *Inst,
98104
SmallPtrSetImpl<Instruction *> &Stores,
99105
DominatorTree &DT, LoopInfo &LI, AAResults &AA) {
100106

101-
// Don't sink static alloca instructions. CodeGen assumes allocas outside the
102-
// entry block are dynamically sized stack objects.
103-
if (AllocaInst *AI = dyn_cast<AllocaInst>(Inst))
104-
if (AI->isStaticAlloca())
105-
return false;
106-
107107
// Check if it's safe to move the instruction.
108108
if (!isSafeToMove(Inst, AA, Stores))
109109
return false;

0 commit comments

Comments
 (0)