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

Commit ed20c2f

Browse files
committed
ARM: stop emitting blx instructions for most calls on MachO.
I'm really not sure why we were in the first place, it's the linker's job to convert between BL/BLX as necessary. Even worse, using BLX left Thumb calls that could be locally resolved completely unencodable since all offsets to BLX are multiples of 4. rdar://26182344 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269101 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6f3d7b4 commit ed20c2f

29 files changed

+128
-179
lines changed

lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,6 @@ const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const {
11121112
case ARMISD::CALL: return "ARMISD::CALL";
11131113
case ARMISD::CALL_PRED: return "ARMISD::CALL_PRED";
11141114
case ARMISD::CALL_NOLINK: return "ARMISD::CALL_NOLINK";
1115-
case ARMISD::tCALL: return "ARMISD::tCALL";
11161115
case ARMISD::BRCOND: return "ARMISD::BRCOND";
11171116
case ARMISD::BR_JT: return "ARMISD::BR_JT";
11181117
case ARMISD::BR2_JT: return "ARMISD::BR2_JT";
@@ -1909,7 +1908,7 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
19091908
if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps())
19101909
CallOpc = ARMISD::CALL_NOLINK;
19111910
else
1912-
CallOpc = isARMFunc ? ARMISD::CALL : ARMISD::tCALL;
1911+
CallOpc = ARMISD::CALL;
19131912
} else {
19141913
if (!isDirect && !Subtarget->hasV5TOps())
19151914
CallOpc = ARMISD::CALL_NOLINK;

lib/Target/ARM/ARMISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace llvm {
4343
CALL, // Function call.
4444
CALL_PRED, // Function call that's predicable.
4545
CALL_NOLINK, // Function call with branch not branch-and-link.
46-
tCALL, // Thumb function call.
4746
BRCOND, // Conditional branch.
4847
BR_JT, // Jumptable branch.
4948
BR2_JT, // Jumptable branch (2 level - jumptable entry is a jump).

lib/Target/ARM/ARMInstrThumb.td

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
// Thumb specific DAG Nodes.
1616
//
1717

18-
def ARMtcall : SDNode<"ARMISD::tCALL", SDT_ARMcall,
19-
[SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
20-
SDNPVariadic]>;
21-
2218
def imm_sr_XFORM: SDNodeXForm<imm, [{
2319
unsigned Imm = N->getZExtValue();
2420
return CurDAG->getTargetConstant((Imm == 32 ? 0 : Imm), SDLoc(N), MVT::i32);
@@ -460,7 +456,7 @@ let isCall = 1,
460456
def tBL : TIx2<0b11110, 0b11, 1,
461457
(outs), (ins pred:$p, t_bltarget:$func), IIC_Br,
462458
"bl${p}\t$func",
463-
[(ARMtcall tglobaladdr:$func)]>,
459+
[(ARMcall tglobaladdr:$func)]>,
464460
Requires<[IsThumb]>, Sched<[WriteBrL]> {
465461
bits<24> func;
466462
let Inst{26} = func{23};
@@ -473,8 +469,7 @@ let isCall = 1,
473469
// ARMv5T and above, also used for Thumb2
474470
def tBLXi : TIx2<0b11110, 0b11, 0,
475471
(outs), (ins pred:$p, t_blxtarget:$func), IIC_Br,
476-
"blx${p}\t$func",
477-
[(ARMcall tglobaladdr:$func)]>,
472+
"blx${p}\t$func", []>,
478473
Requires<[IsThumb, HasV5T, IsNotMClass]>, Sched<[WriteBrL]> {
479474
bits<24> func;
480475
let Inst{26} = func{23};
@@ -488,7 +483,7 @@ let isCall = 1,
488483
// Also used for Thumb2
489484
def tBLXr : TI<(outs), (ins pred:$p, GPR:$func), IIC_Br,
490485
"blx${p}\t$func",
491-
[(ARMtcall GPR:$func)]>,
486+
[(ARMcall GPR:$func)]>,
492487
Requires<[IsThumb, HasV5T]>,
493488
T1Special<{1,1,1,?}>, Sched<[WriteBrL]> { // A6.2.3 & A8.6.24;
494489
bits<4> func;
@@ -1380,11 +1375,9 @@ def : T1Pat<(ARMWrapperJT tjumptable:$dst),
13801375
(tLEApcrelJT tjumptable:$dst)>;
13811376

13821377
// Direct calls
1383-
def : T1Pat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>,
1378+
def : T1Pat<(ARMcall texternalsym:$func), (tBL texternalsym:$func)>,
13841379
Requires<[IsThumb]>;
13851380

1386-
def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>,
1387-
Requires<[IsThumb, HasV5T, IsNotMClass]>;
13881381

13891382
// Indirect calls to ARM routines
13901383
def : Tv5Pat<(ARMcall GPR:$dst), (tBLXr GPR:$dst)>,

test/CodeGen/ARM/2010-11-29-PrologueBug.ll

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=ARM
2-
; RUN: llc < %s -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=THUMB2
1+
; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s
2+
; RUN: llc < %s -mtriple=thumbv7-apple-ios | FileCheck %s
33
; rdar://8690640
44

55
define i32* @t(i32* %x) nounwind {
66
entry:
7-
; ARM-LABEL: t:
8-
; ARM: push
9-
; ARM: mov r7, sp
10-
; ARM: bl _foo
11-
; ARM: bl _foo
12-
; ARM: bl _foo
13-
; ARM: pop {r7, pc}
7+
; CHECK-LABEL: t:
8+
; CHECK: push
9+
; CHECK: mov r7, sp
10+
; CHECK: bl _foo
11+
; CHECK: bl _foo
12+
; CHECK: bl _foo
13+
; CHECK: pop {r7, pc}
1414

15-
; THUMB2-LABEL: t:
16-
; THUMB2: push
17-
; THUMB2: mov r7, sp
18-
; THUMB2: blx _foo
19-
; THUMB2: blx _foo
20-
; THUMB2: blx _foo
21-
; THUMB2: pop
2215
%0 = tail call i32* @foo(i32* %x) nounwind
2316
%1 = tail call i32* @foo(i32* %0) nounwind
2417
%2 = tail call i32* @foo(i32* %1) nounwind

test/CodeGen/ARM/2011-04-15-AndVFlagPeepholeBug.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; CHECK: _f
44
; CHECK-NOT: ands
55
; CHECK: cmp
6-
; CHECK: blxle _g
6+
; CHECK: blle _g
77

88
define i32 @f(i32 %a, i32 %b) nounwind ssp {
99
entry:

test/CodeGen/ARM/2011-04-15-RegisterCmpPeephole.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; CHECK: _f
44
; CHECK: adds
55
; CHECK-NOT: cmp
6-
; CHECK: blxeq _h
6+
; CHECK: bleq _h
77

88
define i32 @f(i32 %a, i32 %b) nounwind ssp {
99
entry:
@@ -22,7 +22,7 @@ if.end: ; preds = %if.then, %entry
2222
; CHECK: _g
2323
; CHECK: orrs
2424
; CHECK-NOT: cmp
25-
; CHECK: blxeq _h
25+
; CHECK: bleq _h
2626

2727
define i32 @g(i32 %a, i32 %b) nounwind ssp {
2828
entry:

test/CodeGen/ARM/2011-04-26-SchedTweak.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ bb:
3838
bb1:
3939
; CHECK: %bb1
4040
; CHECK-NOT: umull
41-
; CHECK: blx _Get
41+
; CHECK: bl _Get
4242
; CHECK: umull
43-
; CHECK: blx _foo
43+
; CHECK: bl _foo
4444
%tmp5 = load i32, i32* %block_size, align 4
4545
%tmp6 = load i32, i32* %block_count, align 4
4646
%tmp7 = call %struct.FF* @Get() nounwind

test/CodeGen/ARM/2011-06-09-TailCallByVal.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ target triple = "thumbv7-apple-darwin10"
2929
@"\01_fnmatch.initial" = external constant %union.__mbstate_t, align 4
3030

3131
; CHECK: _fnmatch
32-
; CHECK: blx _fnmatch1
32+
; CHECK: bl _fnmatch1
3333

3434
define i32 @"\01_fnmatch"(i8* %pattern, i8* %string, i32 %flags) nounwind optsize {
3535
entry:

0 commit comments

Comments
 (0)