From 67e1ff026dabd763509c9f2b0574e8c9d8bebd04 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Wed, 24 Aug 2016 21:21:29 +0000 Subject: [PATCH] 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 --- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 3 ++- .../{thumb-cb-negative-offsets.s => thumb-cb-offsets.s} | 7 +++++++ test/MC/ARM/thumb-cb-thumbfunc.s | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) rename test/MC/ARM/{thumb-cb-negative-offsets.s => thumb-cb-offsets.s} (86%) create mode 100644 test/MC/ARM/thumb-cb-thumbfunc.s diff --git a/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 64c51806b20..5342669f3d8 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -710,7 +710,8 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm, (unsigned)Fixup.getKind() != ARM::fixup_arm_adr_pcrel_12 && (unsigned)Fixup.getKind() != ARM::fixup_thumb_adr_pcrel_10 && (unsigned)Fixup.getKind() != ARM::fixup_t2_adr_pcrel_12 && - (unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cp) { + (unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cp && + (unsigned)Fixup.getKind() != ARM::fixup_arm_thumb_cb) { if (Sym) { if (Asm.isThumbFunc(Sym)) Value |= 1; diff --git a/test/MC/ARM/thumb-cb-negative-offsets.s b/test/MC/ARM/thumb-cb-offsets.s similarity index 86% rename from test/MC/ARM/thumb-cb-negative-offsets.s rename to test/MC/ARM/thumb-cb-offsets.s index 8abff68de14..3a70d4479fd 100644 --- a/test/MC/ARM/thumb-cb-negative-offsets.s +++ b/test/MC/ARM/thumb-cb-offsets.s @@ -24,6 +24,13 @@ label1: label2: nop +@ CHECK: out of range pc-relative fixup value + cbz r0, label4 + .space 33 +label4: + nop + + .align 2 @ CHECK-NOT: label3 cbnz r0, label3 .space 128 diff --git a/test/MC/ARM/thumb-cb-thumbfunc.s b/test/MC/ARM/thumb-cb-thumbfunc.s new file mode 100644 index 00000000000..12995f2a449 --- /dev/null +++ b/test/MC/ARM/thumb-cb-thumbfunc.s @@ -0,0 +1,8 @@ +@ RUN: llvm-mc -triple thumbv7-apple-macho -filetype=obj -o %t %s +@ RUN: llvm-objdump -d -triple thumbv7 %t | FileCheck %s + +@ CHECK: cbnz r0, #0 + .thumb_func label4 + cbnz r0, label4 + .space 2 +label4: