Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit a90b36e

Browse files
author
Weiming Zhao
committed
[Thumb-1] Fix corner cases for compressed jump tables
Summary: When synthesized TBB/TBH is expanded, we need to avoid the case of: BaseReg is redefined after the load of branching target. E.g.: %R2 = tLEApcrelJT <jt#1> %R1 = tLDRr %R1, %R2 ==> %R2 = tLEApcrelJT <jt#1> %R2 = tLDRspi %SP, 12 %R2 = tLDRspi %SP, 12 tBR_JTr %R1 tTBB_JT %R2, %R1 ` Reviewers: jmolloy Reviewed By: jmolloy Subscribers: llvm-commits, rengolin Differential Revision: https://reviews.llvm.org/D32250 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300870 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b2a1e24 commit a90b36e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,15 @@ bool ARMConstantIslands::optimizeThumb2JumpTables() {
21572157

21582158
// If we're in PIC mode, there should be another ADD following.
21592159
auto *TRI = STI->getRegisterInfo();
2160+
2161+
// %base cannot be redefined after the load as it will appear before
2162+
// TBB/TBH like:
2163+
// %base =
2164+
// %base =
2165+
// tBB %base, %idx
2166+
if (registerDefinedBetween(BaseReg, Load->getNextNode(), MBB->end(), TRI))
2167+
continue;
2168+
21602169
if (isPositionIndependentOrROPI) {
21612170
MachineInstr *Add = Load->getNextNode();
21622171
if (Add->getOpcode() != ARM::tADDrr ||

0 commit comments

Comments
 (0)