[PATCH] D23501: Correct the upper bound for a CBZ/CBNZ branch target.

Prakhar Bahuguna via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 04:44:55 PDT 2016


prakhar created this revision.
prakhar added reviewers: olista01, rengolin, t.p.northover.
prakhar added a subscriber: llvm-commits.

Fix for the upper bound check that was causing a build failure.

https://reviews.llvm.org/D23501

Files:
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  test/MC/ARM/thumb-cb-negative-offsets.s

Index: test/MC/ARM/thumb-cb-negative-offsets.s
===================================================================
--- test/MC/ARM/thumb-cb-negative-offsets.s
+++ test/MC/ARM/thumb-cb-negative-offsets.s
@@ -17,3 +17,10 @@
   .space 1000
 label1:
   .word 4
+
+@ CHECK: out of range pc-relative fixup value
+  cbz r0, label2
+  cbnz r0, label2
+  .space 126
+label2:
+  .word 4
Index: lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
===================================================================
--- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -579,7 +579,7 @@
     return ((Value - 4) >> 2) & 0xff;
   case ARM::fixup_arm_thumb_cb: {
     // CB instructions can only branch to offsets in [0, 126] in multiples of 2
-    if (Ctx && ((int64_t)Value < 0 || Value > 0x3e || Value & 1)) {
+    if (Ctx && ((int64_t)Value < 0 || Value > 0x80 || Value & 1)) {
       Ctx->reportError(Fixup.getLoc(), "out of range pc-relative fixup value");
       return 0;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23501.68015.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160815/ecb60164/attachment.bin>


More information about the llvm-commits mailing list