Skip to content

Revert "[TailDuplicator] Do not restrict the computed gotos" #132431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions llvm/include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,17 +994,8 @@ class MachineInstr

/// Return true if this is an indirect branch, such as a
/// branch through a register.
bool isIndirectBranch(QueryType Type = AnyInBundle,
bool IncludeJumpTable = true) const {
return hasProperty(MCID::IndirectBranch, Type) &&
(IncludeJumpTable || !llvm::any_of(operands(), [](const auto &Op) {
return Op.isJTI();
}));
}

bool isComputedGoto(QueryType Type = AnyInBundle) const {
// Jump tables are not considered computed gotos.
return isIndirectBranch(Type, /*IncludeJumpTable=*/false);
bool isIndirectBranch(QueryType Type = AnyInBundle) const {
return hasProperty(MCID::IndirectBranch, Type);
}

/// Return true if this is a branch which may fall
Expand Down
12 changes: 2 additions & 10 deletions llvm/lib/CodeGen/TailDuplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,8 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple,
// that rearrange the predecessors of the indirect branch.

bool HasIndirectbr = false;
bool HasComputedGoto = false;
if (!TailBB.empty()) {
if (!TailBB.empty())
HasIndirectbr = TailBB.back().isIndirectBranch();
HasComputedGoto = TailBB.back().isComputedGoto();
}

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

This file was deleted.