Skip to content

Commit 3b74224

Browse files
author
Jirui Wu
committed
[ARM] Remove a redundant function fixupBTI
Since the redundant BTI instructions emitted by jump tables are now removed in the ARMBranchTargets pass, the fixupBTI function is not needed in the ARMConstantIslandPass. Some related tests are removed as well. The relevant patch that removes the redundant BTI instructions: https://reviews.llvm.org/D144470 Differential Revision: https://reviews.llvm.org/D145048
1 parent ed05dcc commit 3b74224

File tree

3 files changed

+0
-516
lines changed

3 files changed

+0
-516
lines changed

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ namespace {
277277
unsigned &DeadSize, bool &CanDeleteLEA,
278278
bool &BaseRegKill);
279279
bool optimizeThumb2JumpTables();
280-
void fixupBTI(unsigned JTI, MachineBasicBlock &OldBB,
281-
MachineBasicBlock &NewBB);
282280
MachineBasicBlock *adjustJTTargetBlockForward(unsigned JTI,
283281
MachineBasicBlock *BB,
284282
MachineBasicBlock *JTBB);
@@ -2455,38 +2453,6 @@ bool ARMConstantIslands::reorderThumb2JumpTables() {
24552453
return MadeChange;
24562454
}
24572455

2458-
void ARMConstantIslands::fixupBTI(unsigned JTI, MachineBasicBlock &OldBB,
2459-
MachineBasicBlock &NewBB) {
2460-
assert(isThumb2 && "BTI in Thumb1?");
2461-
2462-
// Insert a BTI instruction into NewBB
2463-
BuildMI(NewBB, NewBB.begin(), DebugLoc(), TII->get(ARM::t2BTI));
2464-
2465-
// Update jump table reference counts.
2466-
const MachineJumpTableInfo &MJTI = *MF->getJumpTableInfo();
2467-
const MachineJumpTableEntry &JTE = MJTI.getJumpTables()[JTI];
2468-
for (const MachineBasicBlock *MBB : JTE.MBBs) {
2469-
if (MBB != &OldBB)
2470-
continue;
2471-
--BlockJumpTableRefCount[MBB];
2472-
++BlockJumpTableRefCount[&NewBB];
2473-
}
2474-
2475-
// If the old basic block reference count dropped to zero, remove
2476-
// the BTI instruction at its beginning.
2477-
if (BlockJumpTableRefCount[&OldBB] > 0)
2478-
return;
2479-
2480-
// Skip meta instructions
2481-
auto BTIPos = llvm::find_if_not(OldBB.instrs(), [](const MachineInstr &MI) {
2482-
return MI.isMetaInstruction();
2483-
});
2484-
assert(BTIPos->getOpcode() == ARM::t2BTI &&
2485-
"BasicBlock is mentioned in a jump table but does start with BTI");
2486-
if (BTIPos->getOpcode() == ARM::t2BTI)
2487-
BTIPos->eraseFromParent();
2488-
}
2489-
24902456
MachineBasicBlock *ARMConstantIslands::adjustJTTargetBlockForward(
24912457
unsigned JTI, MachineBasicBlock *BB, MachineBasicBlock *JTBB) {
24922458
// If the destination block is terminated by an unconditional branch,
@@ -2546,9 +2512,6 @@ MachineBasicBlock *ARMConstantIslands::adjustJTTargetBlockForward(
25462512
NewBB->addSuccessor(BB);
25472513
JTBB->replaceSuccessor(BB, NewBB);
25482514

2549-
if (MF->getInfo<ARMFunctionInfo>()->branchTargetEnforcement())
2550-
fixupBTI(JTI, *BB, *NewBB);
2551-
25522515
++NumJTInserted;
25532516
return NewBB;
25542517
}

llvm/test/CodeGen/Thumb2/bti-const-island-multiple-jump-tables.mir

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

0 commit comments

Comments
 (0)