From 9c3633f516fbc995abc46f4d0684d0a0411ccaca 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 --- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 3 ++- .../MC/ARM/{thumb-cb-negative-offsets.s => thumb-cb-offsets.s} | 7 +++++++ llvm/test/MC/ARM/thumb-cb-thumbfunc.s | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) rename llvm/test/MC/ARM/{thumb-cb-negative-offsets.s => thumb-cb-offsets.s} (86%) create mode 100644 llvm/test/MC/ARM/thumb-cb-thumbfunc.s diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 64c5180..5342669 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/llvm/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/llvm/test/MC/ARM/thumb-cb-negative-offsets.s b/llvm/test/MC/ARM/thumb-cb-offsets.s similarity index 86% rename from llvm/test/MC/ARM/thumb-cb-negative-offsets.s rename to llvm/test/MC/ARM/thumb-cb-offsets.s index 8abff68..3a70d44 100644 --- a/llvm/test/MC/ARM/thumb-cb-negative-offsets.s +++ b/llvm/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/llvm/test/MC/ARM/thumb-cb-thumbfunc.s b/llvm/test/MC/ARM/thumb-cb-thumbfunc.s new file mode 100644 index 0000000..12995f2 --- /dev/null +++ b/llvm/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: -- 2.7.4