Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit ccee5d3

Browse files
Weiming Zhaoarielb1
authored andcommitted
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 96583da commit ccee5d3

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
@@ -2094,6 +2094,15 @@ bool ARMConstantIslands::optimizeThumb2JumpTables() {
20942094

20952095
// If we're in PIC mode, there should be another ADD following.
20962096
auto *TRI = STI->getRegisterInfo();
2097+
2098+
// %base cannot be redefined after the load as it will appear before
2099+
// TBB/TBH like:
2100+
// %base =
2101+
// %base =
2102+
// tBB %base, %idx
2103+
if (registerDefinedBetween(BaseReg, Load->getNextNode(), MBB->end(), TRI))
2104+
continue;
2105+
20972106
if (isPositionIndependentOrROPI) {
20982107
MachineInstr *Add = Load->getNextNode();
20992108
if (Add->getOpcode() != ARM::tADDrr ||

0 commit comments

Comments
 (0)