From 3fed2f133ce05fb7ae7079ecdf979f8e3b2fb210 Mon Sep 17 00:00:00 2001 From: Stepan Dyatkovskiy Date: Sat, 29 Mar 2014 13:12:40 +0000 Subject: Recommitted fix for PR18931, with extended tests set. Issue subject: Crash using integrated assembler with immediate arithmetic Fix description: Expressions like 'cmp r0, #(l1 - l2) >> 3' could not be evaluated on asm parsing stage, since it is impossible to resolve labels on this stage. In the end of stage we still have expression (MCExpr). Then, when we want to encode it, we expect it to be an immediate, but it still an expression. Patch introduces a Fixup (MCFixup instance), that is processed after main encoding stage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205094 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/MC/ARM/cmp-immediate-fixup-error.s | 7 +++++++ test/MC/ARM/cmp-immediate-fixup-error2.s | 7 +++++++ test/MC/ARM/cmp-immediate-fixup.s | 9 +++++++++ test/MC/ARM/cmp-immediate-fixup2.s | 9 +++++++++ test/MC/ARM/label_offset.s | 8 -------- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 test/MC/ARM/cmp-immediate-fixup-error.s create mode 100644 test/MC/ARM/cmp-immediate-fixup-error2.s create mode 100644 test/MC/ARM/cmp-immediate-fixup.s create mode 100644 test/MC/ARM/cmp-immediate-fixup2.s delete mode 100644 test/MC/ARM/label_offset.s (limited to 'test/MC/ARM') diff --git a/test/MC/ARM/cmp-immediate-fixup-error.s b/test/MC/ARM/cmp-immediate-fixup-error.s new file mode 100644 index 00000000000..25a2368643d --- /dev/null +++ b/test/MC/ARM/cmp-immediate-fixup-error.s @@ -0,0 +1,7 @@ +@ RUN: not llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s 2>&1 | FileCheck %s + +.text + cmp r0, #(l1 - unknownLabel + 4) >> 2 +@ CHECK: error: expected relocatable expression + +l1: diff --git a/test/MC/ARM/cmp-immediate-fixup-error2.s b/test/MC/ARM/cmp-immediate-fixup-error2.s new file mode 100644 index 00000000000..71f7fa141e0 --- /dev/null +++ b/test/MC/ARM/cmp-immediate-fixup-error2.s @@ -0,0 +1,7 @@ +@ RUN: not llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s 2>&1 | FileCheck %s + +.text + cmp r0, #(l1 - unknownLabel) +@ CHECK: error: symbol 'unknownLabel' can not be undefined in a subtraction expression + +l1: diff --git a/test/MC/ARM/cmp-immediate-fixup.s b/test/MC/ARM/cmp-immediate-fixup.s new file mode 100644 index 00000000000..e21d5c20ccd --- /dev/null +++ b/test/MC/ARM/cmp-immediate-fixup.s @@ -0,0 +1,9 @@ +@ PR18931 +@ RUN: llvm-mc < %s -triple=arm-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-objdump --disassemble -arch=arm - | FileCheck %s + + .text +@ CHECK: cmp r2, #1 + cmp r2, #(l2 - l1 + 4) >> 2 +l1: +l2: diff --git a/test/MC/ARM/cmp-immediate-fixup2.s b/test/MC/ARM/cmp-immediate-fixup2.s new file mode 100644 index 00000000000..c091145523c --- /dev/null +++ b/test/MC/ARM/cmp-immediate-fixup2.s @@ -0,0 +1,9 @@ +@ PR18931 +@ RUN: llvm-mc < %s -triple=arm-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-objdump --disassemble -arch=arm - | FileCheck %s + + .text +@ CHECK: cmp r2, #0 + cmp r2, #(l2 - l1) +l1: +l2: diff --git a/test/MC/ARM/label_offset.s b/test/MC/ARM/label_offset.s deleted file mode 100644 index 0aeb3b6ee69..00000000000 --- a/test/MC/ARM/label_offset.s +++ /dev/null @@ -1,8 +0,0 @@ -@ RUN: not llvm-mc -triple=armv7-linux-gnuabi -filetype=obj < %s 2>&1 | FileCheck %s - -.text - cmp r2, #(l2 - l1) >> 6 -@ CHECK: error: invalid operand for instruction - -l1: -l2: -- cgit v1.2.3