diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -1069,7 +1069,6 @@ template bool isSignedOffset() const { if (!isImm()) return false; - if (isa(Imm.Val)) return true; if (const MCConstantExpr *CE = dyn_cast(Imm.Val)) { int64_t Val = CE->getValue(); int64_t Align = 1LL << scale; @@ -1077,7 +1076,8 @@ int64_t Min = -Align * (1LL << (width-1)); return ((Val % Align) == 0) && (Val >= Min) && (Val <= Max); } - return false; + // Delay the checks of symbolic values until they are resolved + return true; } // checks whether this operand is an offset suitable for the LE / diff --git a/llvm/test/MC/ARM/thumb2-b.w-target.s b/llvm/test/MC/ARM/thumb2-b.w-target.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/ARM/thumb2-b.w-target.s @@ -0,0 +1,20 @@ +# RUN: llvm-mc -triple=thumbv7 -filetype=obj %s | llvm-objdump --triple=thumbv7 -d - | FileCheck %s + +.syntax unified + +// arm-linux-gnueabihf-objdump produced +// 0: f3ff 97fc b.w fffffc <.text+0xfffffc> +// 4: f000 b801 b.w a <.text+0xa> + +// llvm-objdump produced the following +// CHECK: 0: ff f3 fc 97 b.w #16777208 <$t.0+0xfffffc> +// CHECK-NEXT: 4: 00 f0 01 b8 b.w #2 <$t.0+0xa> +1: + b.w 1b - 2f + 0x1000000 +2: + b.w . + (3f - 2b + 2) +3: + + + + diff --git a/llvm/test/MC/ARM/thumb2-branch-ranges.s b/llvm/test/MC/ARM/thumb2-branch-ranges.s --- a/llvm/test/MC/ARM/thumb2-branch-ranges.s +++ b/llvm/test/MC/ARM/thumb2-branch-ranges.s @@ -94,3 +94,10 @@ // CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range // CHECK-LABEL: beq.w start6 beq.w start6 + +start7: +// branch to thumb function resolved at assembly time +// CHECK-NOT: error +// CHECK: [[@LINE+1]]:{{[0-9]}}: error: Relocation out of range + b.w start8 - start7 + 0x1000000 +start8: