Skip to content

Commit 56d7a0a

Browse files
authored
Revert "[TailDuplicator] Do not restrict the computed gotos (#114990)"
This reverts commit dd21aac.
1 parent b3e64fb commit 56d7a0a

File tree

3 files changed

+4
-276
lines changed

3 files changed

+4
-276
lines changed

llvm/include/llvm/CodeGen/MachineInstr.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -994,17 +994,8 @@ class MachineInstr
994994

995995
/// Return true if this is an indirect branch, such as a
996996
/// branch through a register.
997-
bool isIndirectBranch(QueryType Type = AnyInBundle,
998-
bool IncludeJumpTable = true) const {
999-
return hasProperty(MCID::IndirectBranch, Type) &&
1000-
(IncludeJumpTable || !llvm::any_of(operands(), [](const auto &Op) {
1001-
return Op.isJTI();
1002-
}));
1003-
}
1004-
1005-
bool isComputedGoto(QueryType Type = AnyInBundle) const {
1006-
// Jump tables are not considered computed gotos.
1007-
return isIndirectBranch(Type, /*IncludeJumpTable=*/false);
997+
bool isIndirectBranch(QueryType Type = AnyInBundle) const {
998+
return hasProperty(MCID::IndirectBranch, Type);
1008999
}
10091000

10101001
/// Return true if this is a branch which may fall

llvm/lib/CodeGen/TailDuplicator.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,8 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple,
601601
// that rearrange the predecessors of the indirect branch.
602602

603603
bool HasIndirectbr = false;
604-
bool HasComputedGoto = false;
605-
if (!TailBB.empty()) {
604+
if (!TailBB.empty())
606605
HasIndirectbr = TailBB.back().isIndirectBranch();
607-
HasComputedGoto = TailBB.back().isComputedGoto();
608-
}
609606

610607
if (HasIndirectbr && PreRegAlloc)
611608
MaxDuplicateCount = TailDupIndirectBranchSize;
@@ -663,12 +660,7 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple,
663660
// Duplicating a BB which has both multiple predecessors and successors will
664661
// may cause huge amount of PHI nodes. If we want to remove this limitation,
665662
// we have to address https://github.com/llvm/llvm-project/issues/78578.
666-
// NB. This basically unfactors computed gotos that were factored early on in
667-
// the compilation process to speed up edge based data flow. If we do not
668-
// unfactor them again, it can seriously pessimize code with many computed
669-
// jumps in the source code, such as interpreters. Therefore we do not
670-
// restrict the computed gotos.
671-
if (!HasComputedGoto && TailBB.pred_size() > TailDupPredSize &&
663+
if (TailBB.pred_size() > TailDupPredSize &&
672664
TailBB.succ_size() > TailDupSuccSize) {
673665
// If TailBB or any of its successors contains a phi, we may have to add a
674666
// large number of additional phis with additional incoming values.

llvm/test/CodeGen/X86/tail-dup-computed-goto.mir

Lines changed: 0 additions & 255 deletions
This file was deleted.

0 commit comments

Comments
 (0)