OSDN Git Service

ARM: don't diagnose cbz/cbnz to Thumb functions.
authorTim Northover <tnorthover@apple.com>
Wed, 24 Aug 2016 21:21:29 +0000 (21:21 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 24 Aug 2016 21:21:29 +0000 (21:21 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279665 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
test/MC/ARM/thumb-cb-offsets.s [moved from test/MC/ARM/thumb-cb-negative-offsets.s with 86% similarity]
test/MC/ARM/thumb-cb-thumbfunc.s [new file with mode: 0644]

index 64c5180..5342669 100644 (file)
@@ -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;
similarity index 86%
rename from test/MC/ARM/thumb-cb-negative-offsets.s
rename to test/MC/ARM/thumb-cb-offsets.s
index 8abff68..3a70d44 100644 (file)
@@ -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 (file)
index 0000000..12995f2
--- /dev/null
@@ -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: