diff options
Diffstat (limited to 'llvm/test/Assembler')
-rw-r--r-- | llvm/test/Assembler/auto_upgrade_intrinsics.ll | 12 | ||||
-rw-r--r-- | llvm/test/Assembler/autoupgrade-lifetime-intrinsics.ll | 17 | ||||
-rw-r--r-- | llvm/test/Assembler/ptrtoaddr-invalid-constexpr.ll | 56 | ||||
-rw-r--r-- | llvm/test/Assembler/ptrtoaddr-invalid.ll | 84 | ||||
-rw-r--r-- | llvm/test/Assembler/ptrtoaddr.ll | 27 |
5 files changed, 184 insertions, 12 deletions
diff --git a/llvm/test/Assembler/auto_upgrade_intrinsics.ll b/llvm/test/Assembler/auto_upgrade_intrinsics.ll index d1b535b..37cb496 100644 --- a/llvm/test/Assembler/auto_upgrade_intrinsics.ll +++ b/llvm/test/Assembler/auto_upgrade_intrinsics.ll @@ -171,10 +171,10 @@ define void @tests.lifetime.start.end() { ; CHECK-LABEL: @tests.lifetime.start.end( %a = alloca i8 call void @llvm.lifetime.start(i64 1, ptr %a) - ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %a) + ; CHECK: call void @llvm.lifetime.start.p0(ptr %a) store i8 0, ptr %a call void @llvm.lifetime.end(i64 1, ptr %a) - ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %a) + ; CHECK: call void @llvm.lifetime.end.p0(ptr %a) ret void } @@ -185,10 +185,10 @@ define void @tests.lifetime.start.end.unnamed() { ; CHECK-LABEL: @tests.lifetime.start.end.unnamed( %a = alloca ptr call void @llvm.lifetime.start.unnamed(i64 1, ptr %a) - ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %a) + ; CHECK: call void @llvm.lifetime.start.p0(ptr %a) store ptr null, ptr %a call void @llvm.lifetime.end.unnamed(i64 1, ptr %a) - ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %a) + ; CHECK: call void @llvm.lifetime.end.p0(ptr %a) ret void } @@ -220,5 +220,5 @@ define void @test.prefetch.unnamed(ptr %ptr) { ; emitted at the end. ; CHECK: declare i32 @llvm.objectsize.i32.p0 -; CHECK: declare void @llvm.lifetime.start.p0(i64 immarg, ptr captures(none)) -; CHECK: declare void @llvm.lifetime.end.p0(i64 immarg, ptr captures(none)) +; CHECK: declare void @llvm.lifetime.start.p0(ptr captures(none)) +; CHECK: declare void @llvm.lifetime.end.p0(ptr captures(none)) diff --git a/llvm/test/Assembler/autoupgrade-lifetime-intrinsics.ll b/llvm/test/Assembler/autoupgrade-lifetime-intrinsics.ll index 00ab934..377c002 100644 --- a/llvm/test/Assembler/autoupgrade-lifetime-intrinsics.ll +++ b/llvm/test/Assembler/autoupgrade-lifetime-intrinsics.ll @@ -5,8 +5,8 @@ define void @strip_bitcast() { ; CHECK-LABEL: define void @strip_bitcast() { ; CHECK-NEXT: [[A:%.*]] = alloca i8, align 1 ; CHECK-NEXT: [[B:%.*]] = bitcast ptr [[A]] to ptr -; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[A]]) -; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[A]]) ; CHECK-NEXT: ret void ; %a = alloca i8 @@ -20,8 +20,8 @@ define void @strip_addrspacecast() { ; CHECK-LABEL: define void @strip_addrspacecast() { ; CHECK-NEXT: [[A:%.*]] = alloca i8, align 1 ; CHECK-NEXT: [[B:%.*]] = addrspacecast ptr [[A]] to ptr addrspace(1) -; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[A]]) -; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[A]]) ; CHECK-NEXT: ret void ; %a = alloca i8 @@ -35,8 +35,8 @@ define void @strip_gep() { ; CHECK-LABEL: define void @strip_gep() { ; CHECK-NEXT: [[A:%.*]] = alloca [2 x i8], align 1 ; CHECK-NEXT: [[B:%.*]] = getelementptr [2 x i8], ptr [[A]], i64 0, i64 0 -; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[A]]) -; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[A]]) +; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[A]]) ; CHECK-NEXT: ret void ; %a = alloca [2 x i8] @@ -55,3 +55,8 @@ define void @remove_unanalyzable(ptr %p) { call void @llvm.lifetime.end.p0(i64 1, ptr %p) ret void } + +declare void @llvm.lifetime.start.p0(i64, ptr) +declare void @llvm.lifetime.end.p0(i64, ptr) +declare void @llvm.lifetime.start.p1(i64, ptr addrspace(1)) +declare void @llvm.lifetime.end.p1(i64, ptr addrspace(1)) diff --git a/llvm/test/Assembler/ptrtoaddr-invalid-constexpr.ll b/llvm/test/Assembler/ptrtoaddr-invalid-constexpr.ll new file mode 100644 index 0000000..665deff --- /dev/null +++ b/llvm/test/Assembler/ptrtoaddr-invalid-constexpr.ll @@ -0,0 +1,56 @@ +;; Check all requirements on the ptrtoaddr constant expression operands +;; Most of these invalid cases are detected at parse time but some are only +;; detected at verification time (see Verifier::visitPtrToAddrInst()) +; RUN: rm -rf %t && split-file --leading-lines %s %t + +;--- src_vec_dst_no_vec.ll +; RUN: not llvm-as %t/src_vec_dst_no_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_VEC_DST_NO_VEC %s --implicit-check-not="error:" +@g = global i64 ptrtoaddr (<2 x ptr> <ptr @g, ptr @g> to i64) +; SRC_VEC_DST_NO_VEC: [[#@LINE-1]]:17: error: invalid cast opcode for cast from '<2 x ptr>' to 'i64' + +;--- src_no_vec_dst_vec.ll +; RUN: not llvm-as %t/src_no_vec_dst_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NO_VEC_DST_VEC %s --implicit-check-not="error:" +@g = global <2 x i64> ptrtoaddr (ptr @g to <2 x i64>) +; SRC_NO_VEC_DST_VEC: [[#@LINE-1]]:23: error: invalid cast opcode for cast from 'ptr' to '<2 x i64>' + +;--- dst_not_int.ll +; RUN: not llvm-as %t/dst_not_int.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_INT %s --implicit-check-not="error:" +@g = global float ptrtoaddr (ptr @g to float) +; DST_NOT_INT: [[#@LINE-1]]:19: error: invalid cast opcode for cast from 'ptr' to 'float' + +;--- dst_not_int_vec.ll +; RUN: not llvm-as %t/dst_not_int_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_INT_VEC %s --implicit-check-not="error:" +@g = global <2 x float> ptrtoaddr (<2 x ptr> <ptr @g, ptr @g> to <2 x float>) +; DST_NOT_INT_VEC: [[#@LINE-1]]:25: error: invalid cast opcode for cast from '<2 x ptr>' to '<2 x float>' + +;--- src_not_ptr.ll +; RUN: not llvm-as %t/src_not_ptr.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NOT_PTR %s --implicit-check-not="error:" +@g = global i64 ptrtoaddr (i32 1 to i64) +; SRC_NOT_PTR: [[#@LINE-1]]:17: error: invalid cast opcode for cast from 'i32' to 'i64' + +;--- src_not_ptr_vec.ll +; RUN: not llvm-as %t/src_not_ptr_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NOT_PTR_VEC %s --implicit-check-not="error:" +@g = global <2 x i64> ptrtoaddr (<2 x i32> <i32 1, i32 2> to <2 x i64>) +; SRC_NOT_PTR_VEC: [[#@LINE-1]]:23: error: invalid cast opcode for cast from '<2 x i32>' to '<2 x i64>' + +;--- vec_src_fewer_elems.ll +; RUN: not llvm-as %t/vec_src_fewer_elems.ll -o /dev/null 2>&1 | FileCheck -check-prefix=VEC_SRC_FEWER_ELEMS %s --implicit-check-not="error:" +@g = global <4 x i64> ptrtoaddr (<2 x ptr> <ptr @g, ptr @g> to <4 x i64>) +; VEC_SRC_FEWER_ELEMS: [[#@LINE-1]]:23: error: invalid cast opcode for cast from '<2 x ptr>' to '<4 x i64>' + +;--- vec_dst_fewer_elems.ll +; RUN: not llvm-as %t/vec_dst_fewer_elems.ll -o /dev/null 2>&1 | FileCheck -check-prefix=VEC_DST_FEWER_ELEMS %s --implicit-check-not="error:" +@g = global <2 x i64> ptrtoaddr (<4 x ptr> <ptr @g, ptr @g, ptr @g, ptr @g> to <2 x i64>) +; VEC_DST_FEWER_ELEMS: [[#@LINE-1]]:23: error: invalid cast opcode for cast from '<4 x ptr>' to '<2 x i64>' + +;--- dst_not_addr_size.ll +; The following invalid IR is caught by the verifier, not the parser: +; RUN: llvm-as %t/dst_not_addr_size.ll --disable-output --disable-verify +; RUN: not llvm-as %t/dst_not_addr_size.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_ADDR_SIZE %s --implicit-check-not="error:" +; DST_NOT_ADDR_SIZE: assembly parsed, but does not verify as correct! +@g = global i32 ptrtoaddr (ptr @g to i32) +; DST_NOT_ADDR_SIZE-NEXT: PtrToAddr result must be address width +; DST_NOT_ADDR_SIZE-NEXT: i32 ptrtoaddr (ptr @g to i32) +@g_vec = global <4 x i32> ptrtoaddr (<4 x ptr> <ptr @g, ptr @g, ptr @g, ptr @g> to <4 x i32>) +; TODO: Verifier.cpp does not visit ConstantVector/ConstantStruct values +; TODO-DST_NOT_ADDR_SIZE: PtrToAddr result must be address width diff --git a/llvm/test/Assembler/ptrtoaddr-invalid.ll b/llvm/test/Assembler/ptrtoaddr-invalid.ll new file mode 100644 index 0000000..dff787b --- /dev/null +++ b/llvm/test/Assembler/ptrtoaddr-invalid.ll @@ -0,0 +1,84 @@ +;; Check all requirements on the ptrtoaddr instruction operands +;; Most of these invalid cases are detected at parse time but some are only +;; detected at verification time (see Verifier::visitPtrToAddrInst()) +; RUN: rm -rf %t && split-file --leading-lines %s %t + +;--- src_vec_dst_no_vec.ll +; RUN: not llvm-as %t/src_vec_dst_no_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_VEC_DST_NO_VEC %s --implicit-check-not="error:" +define i64 @bad(<2 x ptr> %p) { + %addr = ptrtoaddr <2 x ptr> %p to i64 + ; SRC_VEC_DST_NO_VEC: [[#@LINE-1]]:21: error: invalid cast opcode for cast from '<2 x ptr>' to 'i64' + ret i64 %addr +} + +;--- src_no_vec_dst_vec.ll +; RUN: not llvm-as %t/src_no_vec_dst_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NO_VEC_DST_VEC %s --implicit-check-not="error:" +define <2 x i64> @bad(ptr %p) { + %addr = ptrtoaddr ptr %p to <2 x i64> + ; SRC_NO_VEC_DST_VEC: [[#@LINE-1]]:21: error: invalid cast opcode for cast from 'ptr' to '<2 x i64>' + ret <2 x i64> %addr +} + +;--- dst_not_int.ll +; RUN: not llvm-as %t/dst_not_int.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_INT %s --implicit-check-not="error:" +define float @bad(ptr %p) { + %addr = ptrtoaddr ptr %p to float + ; DST_NOT_INT: [[#@LINE-1]]:21: error: invalid cast opcode for cast from 'ptr' to 'float' + ret float %addr +} + +;--- dst_not_int_vec.ll +; RUN: not llvm-as %t/dst_not_int_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_INT_VEC %s --implicit-check-not="error:" +define <2 x float> @bad(<2 x ptr> %p) { + %addr = ptrtoaddr <2 x ptr> %p to <2 x float> + ; DST_NOT_INT_VEC: [[#@LINE-1]]:21: error: invalid cast opcode for cast from '<2 x ptr>' to '<2 x float>' + ret <2 x float> %addr +} + +;--- src_not_ptr.ll +; RUN: not llvm-as %t/src_not_ptr.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NOT_PTR %s --implicit-check-not="error:" +define i64 @bad(i32 %p) { + %addr = ptrtoaddr i32 %p to i64 + ; SRC_NOT_PTR: [[#@LINE-1]]:21: error: invalid cast opcode for cast from 'i32' to 'i64' + ret i64 %addr +} + +;--- src_not_ptr_vec.ll +; RUN: not llvm-as %t/src_not_ptr_vec.ll -o /dev/null 2>&1 | FileCheck -check-prefix=SRC_NOT_PTR_VEC %s --implicit-check-not="error:" +define <2 x i64> @bad(<2 x i32> %p) { + %addr = ptrtoaddr <2 x i32> %p to <2 x i64> + ; SRC_NOT_PTR_VEC: [[#@LINE-1]]:21: error: invalid cast opcode for cast from '<2 x i32>' to '<2 x i64>' + ret <2 x i64> %addr +} + +;--- vec_src_fewer_elems.ll +; RUN: not llvm-as %t/vec_src_fewer_elems.ll -o /dev/null 2>&1 | FileCheck -check-prefix=VEC_SRC_FEWER_ELEMS %s --implicit-check-not="error:" +define <4 x i64> @bad(<2 x ptr> %p) { + %addr = ptrtoaddr <2 x ptr> %p to <4 x i64> + ; VEC_SRC_FEWER_ELEMS: [[#@LINE-1]]:21: error: invalid cast opcode for cast from '<2 x ptr>' to '<4 x i64>' + ret <4 x i64> %addr +} + +;--- vec_dst_fewer_elems.ll +; RUN: not llvm-as %t/vec_dst_fewer_elems.ll -o /dev/null 2>&1 | FileCheck -check-prefix=VEC_DST_FEWER_ELEMS %s --implicit-check-not="error:" +define <2 x i64> @bad(<4 x ptr> %p) { + %addr = ptrtoaddr <4 x ptr> %p to <2 x i64> + ; VEC_DST_FEWER_ELEMS: [[#@LINE-1]]:21: error: invalid cast opcode for cast from '<4 x ptr>' to '<2 x i64>' + ret <2 x i64> %addr +} + +;--- dst_not_addr_size.ll +; The following invalid IR is caught by the verifier, not the parser: +; RUN: llvm-as %t/dst_not_addr_size.ll --disable-output --disable-verify +; RUN: not llvm-as %t/dst_not_addr_size.ll -o /dev/null 2>&1 | FileCheck -check-prefix=DST_NOT_ADDR_SIZE %s --implicit-check-not="error:" +; DST_NOT_ADDR_SIZE: assembly parsed, but does not verify as correct! +define i32 @bad(ptr %p) { + %addr = ptrtoaddr ptr %p to i32 + ; DST_NOT_ADDR_SIZE: PtrToAddr result must be address width + ret i32 %addr +} +define <4 x i32> @bad_vec(<4 x ptr> %p) { + %addr = ptrtoaddr <4 x ptr> %p to <4 x i32> + ; DST_NOT_ADDR_SIZE: PtrToAddr result must be address width + ret <4 x i32> %addr +} diff --git a/llvm/test/Assembler/ptrtoaddr.ll b/llvm/test/Assembler/ptrtoaddr.ll new file mode 100644 index 0000000..f21410b --- /dev/null +++ b/llvm/test/Assembler/ptrtoaddr.ll @@ -0,0 +1,27 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s +target datalayout = "p1:64:64:64:32" + +@i_as0 = global i32 0 +@global_cast_as0 = global i64 ptrtoaddr (ptr @i_as0 to i64) +; CHECK: @global_cast_as0 = global i64 ptrtoaddr (ptr @i_as0 to i64) +@i_as1 = addrspace(1) global i32 0 +@global_cast_as1 = global i32 ptrtoaddr (ptr addrspace(1) @i_as1 to i32) +; CHECK: @global_cast_as1 = global i32 ptrtoaddr (ptr addrspace(1) @i_as1 to i32) + +define i64 @test_as0(ptr %p) { + %addr = ptrtoaddr ptr %p to i64 + ; CHECK: %addr = ptrtoaddr ptr %p to i64 + ret i64 %addr +} + +define i32 @test_as1(ptr addrspace(1) %p) { + %addr = ptrtoaddr ptr addrspace(1) %p to i32 + ; CHECK: %addr = ptrtoaddr ptr addrspace(1) %p to i32 + ret i32 %addr +} + +define <2 x i32> @test_vec_as1(<2 x ptr addrspace(1)> %p) { + %addr = ptrtoaddr <2 x ptr addrspace(1)> %p to <2 x i32> + ; CHECK: %addr = ptrtoaddr <2 x ptr addrspace(1)> %p to <2 x i32> + ret <2 x i32> %addr +} |