diff options
author | Bill Wendling <isanbard@gmail.com> | 2019-08-03 05:52:47 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2019-08-03 05:52:47 +0000 |
commit | 41a2847a9ae50a9cc52f754d52692357d0e28bbf (patch) | |
tree | e4e1ac32196becabe24a43689823b64c70c21ac7 /llvm/test/CodeGen | |
parent | 10bf563171c5daf8e9bf8cf52f57f0790e1ff853 (diff) | |
download | bcm5719-llvm-41a2847a9ae50a9cc52f754d52692357d0e28bbf.tar.gz bcm5719-llvm-41a2847a9ae50a9cc52f754d52692357d0e28bbf.zip |
Emit diagnostic if an inline asm constraint requires an immediate
Summary:
An inline asm call can result in an immediate after inlining. Therefore emit a
diagnostic here if constraint requires an immediate but one isn't supplied.
Reviewers: joerg, mgorny, efriedma, rsmith
Reviewed By: joerg
Subscribers: asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, s.egerton, MaskRay, jyknight, dylanmckay, javed.absar, fedor.sergeev, jrtc27, Jim, krytarowski, eraman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60942
llvm-svn: 367750
Diffstat (limited to 'llvm/test/CodeGen')
11 files changed, 49 insertions, 12 deletions
diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-I.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-I.ll index 7dc9f726003..7784c9b2442 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-I.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-I.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'I' +; CHECK-ERRORS: error: value out of range for constraint 'I' define i32 @constraint_I(i32 %i, i32 %j) nounwind ssp { entry: diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-J.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-J.ll index 592875b0cb0..c90178513d2 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-J.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-J.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'J' +; CHECK-ERRORS: error: value out of range for constraint 'J' define i32 @constraint_J(i32 %i, i32 %j) nounwind ssp { entry: diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-K.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-K.ll index 893e8d29e65..e5baf85e954 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-K.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-K.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'K' +; CHECK-ERRORS: error: value out of range for constraint 'K' define i32 @constraint_K(i32 %i, i32 %j) nounwind { entry: diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-L.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-L.ll index b2fb822aa29..cdba0562755 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-L.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-L.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'L' +; CHECK-ERRORS: error: value out of range for constraint 'L' define i32 @constraint_L(i32 %i, i32 %j) nounwind { entry: diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-M.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-M.ll index aaee933fd6d..c7a786b26bb 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-M.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-M.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'M' +; CHECK-ERRORS: error: value out of range for constraint 'M' define i32 @constraint_M(i32 %i, i32 %j) nounwind { entry: diff --git a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-N.ll b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-N.ll index d1d2e03548e..38b0ab8fa29 100644 --- a/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-N.ll +++ b/llvm/test/CodeGen/AArch64/arm64-inline-asm-error-N.ll @@ -2,7 +2,7 @@ ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s ; Check for at least one invalid constant. -; CHECK-ERRORS: error: invalid operand for inline asm constraint 'N' +; CHECK-ERRORS: error: value out of range for constraint 'N' define i32 @constraint_N(i32 %i, i32 %j) nounwind { entry: diff --git a/llvm/test/CodeGen/RISCV/inline-asm-invalid.ll b/llvm/test/CodeGen/RISCV/inline-asm-invalid.ll index 06b0f2c2bfe..20ac5ef1111 100644 --- a/llvm/test/CodeGen/RISCV/inline-asm-invalid.ll +++ b/llvm/test/CodeGen/RISCV/inline-asm-invalid.ll @@ -2,23 +2,23 @@ ; RUN: not llc -mtriple=riscv64 < %s 2>&1 | FileCheck %s define void @constraint_I() { -; CHECK: error: invalid operand for inline asm constraint 'I' +; CHECK: error: value out of range for constraint 'I' tail call void asm sideeffect "addi a0, a0, $0", "I"(i32 2048) -; CHECK: error: invalid operand for inline asm constraint 'I' +; CHECK: error: value out of range for constraint 'I' tail call void asm sideeffect "addi a0, a0, $0", "I"(i32 -2049) ret void } define void @constraint_J() { -; CHECK: error: invalid operand for inline asm constraint 'J' +; CHECK: error: value out of range for constraint 'J' tail call void asm sideeffect "addi a0, a0, $0", "J"(i32 1) ret void } define void @constraint_K() { -; CHECK: error: invalid operand for inline asm constraint 'K' +; CHECK: error: value out of range for constraint 'K' tail call void asm sideeffect "csrwi mstatus, $0", "K"(i32 32) -; CHECK: error: invalid operand for inline asm constraint 'K' +; CHECK: error: value out of range for constraint 'K' tail call void asm sideeffect "csrwi mstatus, $0", "K"(i32 -1) ret void } diff --git a/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll b/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll index 967477d076d..a3099ab3679 100644 --- a/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll +++ b/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll @@ -2,7 +2,7 @@ @x = global i32 0, align 4 -;CHECK: error: invalid operand for inline asm constraint 'n' +; CHECK: error: constraint 'n' expects an integer constant expression define void @foo() { %a = getelementptr i32, i32* @x, i32 1 call void asm sideeffect "foo $0", "n"(i32* %a) nounwind diff --git a/llvm/test/CodeGen/X86/inline-asm-e-constraint.ll b/llvm/test/CodeGen/X86/inline-asm-e-constraint.ll new file mode 100644 index 00000000000..fd10ba42408 --- /dev/null +++ b/llvm/test/CodeGen/X86/inline-asm-e-constraint.ll @@ -0,0 +1,17 @@ +; RUN: not llc -mtriple=x86_64-unknown-unknown -no-integrated-as < %s 2>&1 | FileCheck %s + +%struct.s = type { i32, i32 } + +@pr40890.s = internal global %struct.s zeroinitializer, align 4 + +; CHECK: error: invalid operand for inline asm constraint 'e' +; CHECK: error: invalid operand for inline asm constraint 'e' + +define void @pr40890() { +entry: + ; This pointer cannot be used as an integer constant expression. + tail call void asm sideeffect "\0A#define GLOBAL_A abcd$0\0A", "e,~{dirflag},~{fpsr},~{flags}"(i32* getelementptr inbounds (%struct.s, %struct.s* @pr40890.s, i64 0, i32 0)) + ; Floating-point is also not okay. + tail call void asm sideeffect "\0A#define PI abcd$0\0A", "e,~{dirflag},~{fpsr},~{flags}"(float 0x40091EB860000000) + ret void +} diff --git a/llvm/test/CodeGen/X86/inline-asm-imm-out-of-range.ll b/llvm/test/CodeGen/X86/inline-asm-imm-out-of-range.ll new file mode 100644 index 00000000000..9c5177d02a1 --- /dev/null +++ b/llvm/test/CodeGen/X86/inline-asm-imm-out-of-range.ll @@ -0,0 +1,7 @@ +; RUN: not llc -mtriple=i686-- -no-integrated-as < %s 2>&1 | FileCheck %s + +; CHECK: error: value out of range for constraint 'I' +define void @foo() { + call void asm sideeffect "foo $0", "I"(i32 42) + ret void +} diff --git a/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll b/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll new file mode 100644 index 00000000000..669e464f1f6 --- /dev/null +++ b/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll @@ -0,0 +1,13 @@ +; RUN: llc -mtriple=x86_64-unknown-unknown -no-integrated-as < %s 2>&1 | FileCheck %s + +@x = global i32 0, align 4 + +define void @foo() { +; CHECK-LABEL: foo: + call void asm sideeffect "foo $0", "n"(i32 42) nounwind +; CHECK: #APP +; CHECK-NEXT: foo $42 +; CHECK-NEXT: #NO_APP + ret void +; CHECK-NEXT: retq +} |