Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions llvm/include/llvm/CodeGen/MachineBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ class MachineBasicBlock
const MachineFunction *getParent() const { return xParent; }
MachineFunction *getParent() { return xParent; }

bool terminatorIsComputedGoto() const {
return back().isIndirectBranch() &&
llvm::all_of(successors(), [](const MachineBasicBlock *Succ) {
return Succ->isIRBlockAddressTaken();
});
}

using instr_iterator = Instructions::iterator;
using const_instr_iterator = Instructions::const_iterator;
using reverse_instr_iterator = Instructions::reverse_iterator;
Expand Down
11 changes: 2 additions & 9 deletions llvm/include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +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 || jumpToIRBlockAddressTaken());
}

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
7 changes: 0 additions & 7 deletions llvm/lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@ void MachineInstr::setExtraInfo(MachineFunction &MF,
Info.set<EIIK_MMO>(MMOs[0]);
}

bool MachineInstr::jumpToIRBlockAddressTaken() const {
return llvm::all_of(getParent()->successors(),
[](const MachineBasicBlock *Succ) {
return Succ->isIRBlockAddressTaken();
});
}

void MachineInstr::dropMemRefs(MachineFunction &MF) {
if (memoperands_empty())
return;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/TailDuplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple,
bool HasComputedGoto = false;
if (!TailBB.empty()) {
HasIndirectbr = TailBB.back().isIndirectBranch();
HasComputedGoto = TailBB.back().isComputedGoto();
HasComputedGoto = TailBB.terminatorIsComputedGoto();
}

if (HasIndirectbr && PreRegAlloc)
Expand Down