Skip to content

Commit 9c3633f

Browse files
committed
ARM: don't diagnose cbz/cbnz to Thumb functions.
A branch-distance to a Thumb function shouldn't be forced to be odd for CBZ/CBNZ instructions because (assuming it's within range), it's going to be a valid, even offset. llvm-svn: 279665
1 parent 8e7ea9d commit 9c3633f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm,
710710
(unsigned)Fixup.getKind() != ARM::fixup_arm_adr_pcrel_12 &&
711711
(unsigned)Fixup.getKind() != ARM::fixup_thumb_adr_pcrel_10 &&
712712
(unsigned)Fixup.getKind() != ARM::fixup_t2_adr_pcrel_12 &&
713-
(unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cp) {
713+
(unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cp &&
714+
(unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cb) {
714715
if (Sym) {
715716
if (Asm.isThumbFunc(Sym))
716717
Value |= 1;

llvm/test/MC/ARM/thumb-cb-negative-offsets.s renamed to llvm/test/MC/ARM/thumb-cb-offsets.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ label1:
2424
label2:
2525
nop
2626

27+
@ CHECK: out of range pc-relative fixup value
28+
cbz r0, label4
29+
.space 33
30+
label4:
31+
nop
32+
33+
.align 2
2734
@ CHECK-NOT: label3
2835
cbnz r0, label3
2936
.space 128

llvm/test/MC/ARM/thumb-cb-thumbfunc.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@ RUN: llvm-mc -triple thumbv7-apple-macho -filetype=obj -o %t %s
2+
@ RUN: llvm-objdump -d -triple thumbv7 %t | FileCheck %s
3+
4+
@ CHECK: cbnz r0, #0
5+
.thumb_func label4
6+
cbnz r0, label4
7+
.space 2
8+
label4:

0 commit comments

Comments
 (0)