Skip to content

Commit 9cfbd46

Browse files
committed
Move all checks for unsafe instructions info one function
Signed-off-by: John Lu <[email protected]>
1 parent 82f1f5e commit 9cfbd46

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Transforms/Scalar/Sink.cpp

Lines changed: 6 additions & 6 deletions
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)
@@ -103,12 +109,6 @@ static bool SinkInstruction(Instruction *Inst,
103109
SmallPtrSetImpl<Instruction *> &Stores,
104110
DominatorTree &DT, LoopInfo &LI, AAResults &AA) {
105111

106-
// Don't sink static alloca instructions. CodeGen assumes allocas outside the
107-
// entry block are dynamically sized stack objects.
108-
if (AllocaInst *AI = dyn_cast<AllocaInst>(Inst))
109-
if (AI->isStaticAlloca())
110-
return false;
111-
112112
// Check if it's safe to move the instruction.
113113
if (!isSafeToMove(Inst, AA, Stores))
114114
return false;

0 commit comments

Comments
 (0)