Skip to content

[ARM] Remove unused class member in ARMConstantIslandPass #141093

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

statham-arm
Copy link
Collaborator

The map variable BlockJumpTableRefCount was added in commit f5f28d5 to track whether a basic block was the target of any jump table entries. This was used in the function fixupBTI to insert and remove BTIs after jump tables had been modified.

Commit 3b74224 removed fixupBTI on the grounds that the work was now being done elsewhere. That left BlockJumpTableRefCount still being created, but now nothing is using it. So we can garbage-collect that variable and all the code that populates it.

The map variable `BlockJumpTableRefCount` was added in commit
f5f28d5 to track whether a basic
block was the target of any jump table entries. This was used in the
function `fixupBTI` to insert and remove BTIs after jump tables had
been modified.

Commit 3b74224 removed `fixupBTI` on
the grounds that the work was now being done elsewhere. That left
`BlockJumpTableRefCount` still being created, but now nothing is using
it. So we can garbage-collect that variable and all the code that
populates it.
@llvmbot
Copy link
Member

llvmbot commented May 22, 2025

@llvm/pr-subscribers-backend-arm

Author: Simon Tatham (statham-arm)

Changes

The map variable BlockJumpTableRefCount was added in commit f5f28d5 to track whether a basic block was the target of any jump table entries. This was used in the function fixupBTI to insert and remove BTIs after jump tables had been modified.

Commit 3b74224 removed fixupBTI on the grounds that the work was now being done elsewhere. That left BlockJumpTableRefCount still being created, but now nothing is using it. So we can garbage-collect that variable and all the code that populates it.


Full diff: https://github.com/llvm/llvm-project/pull/141093.diff

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/ARMConstantIslandPass.cpp (-26)
diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
index 2972316fcee00..4b2fab2939af0 100644
--- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -183,9 +183,6 @@ namespace {
     /// base address.
     DenseMap<int, int> JumpTableUserIndices;
 
-    // Maps a MachineBasicBlock to the number of jump tables entries.
-    DenseMap<const MachineBasicBlock *, int> BlockJumpTableRefCount;
-
     /// ImmBranch - One per immediate branch, keeping the machine instruction
     /// pointer, conditional or unconditional, the max displacement,
     /// and (if isCond is true) the corresponding unconditional branch
@@ -523,7 +520,6 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
   CPEntries.clear();
   JumpTableEntryIndices.clear();
   JumpTableUserIndices.clear();
-  BlockJumpTableRefCount.clear();
   ImmBranches.clear();
   PushPopMIs.clear();
   T2JumpTables.clear();
@@ -736,14 +732,6 @@ Align ARMConstantIslands::getCPEAlign(const MachineInstr *CPEMI) {
   return MCP->getConstants()[CPI].getAlign();
 }
 
-// Exception landing pads, blocks that has their adress taken, and function
-// entry blocks will always be (potential) indirect jump targets, regardless of
-// whether they are referenced by or not by jump tables.
-static bool isAlwaysIndirectTarget(const MachineBasicBlock &MBB) {
-  return MBB.isEHPad() || MBB.hasAddressTaken() ||
-         &MBB == &MBB.getParent()->front();
-}
-
 /// scanFunctionJumpTables - Do a scan of the function, building up
 /// information about the sizes of each block and the locations of all
 /// the jump tables.
@@ -754,20 +742,6 @@ void ARMConstantIslands::scanFunctionJumpTables() {
           (I.getOpcode() == ARM::t2BR_JT || I.getOpcode() == ARM::tBR_JTr))
         T2JumpTables.push_back(&I);
   }
-
-  if (!MF->getInfo<ARMFunctionInfo>()->branchTargetEnforcement())
-    return;
-
-  if (const MachineJumpTableInfo *JTI = MF->getJumpTableInfo())
-    for (const MachineJumpTableEntry &JTE : JTI->getJumpTables())
-      for (const MachineBasicBlock *MBB : JTE.MBBs) {
-        if (isAlwaysIndirectTarget(*MBB))
-          // Set the reference count essentially to infinity, it will never
-          // reach zero and the BTI Instruction will never be removed.
-          BlockJumpTableRefCount[MBB] = std::numeric_limits<int>::max();
-        else
-          ++BlockJumpTableRefCount[MBB];
-      }
 }
 
 /// initializeFunctionInfo - Do the initial scan of the function, building up

Copy link
Collaborator

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@statham-arm statham-arm merged commit 1d5bf04 into llvm:main May 27, 2025
13 checks passed
@statham-arm statham-arm deleted the remove-blockjumptablerefcount branch May 27, 2025 08:10
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
The map variable `BlockJumpTableRefCount` was added in commit
f5f28d5 to track whether a basic block
was the target of any jump table entries. This was used in the function
`fixupBTI` to insert and remove BTIs after jump tables had been
modified.

Commit 3b74224 removed `fixupBTI` on
the grounds that the work was now being done elsewhere. That left
`BlockJumpTableRefCount` still being created, but now nothing is using
it. So we can garbage-collect that variable and all the code that
populates it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants