From b5d9445a3d9229ec3c6a94e188d7e9c706086d51 Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva Date: Mon, 19 Oct 2020 18:10:19 +0300 Subject: [PATCH 1/2] Lower constant expressions inside metadata operands It is possible that instruction has metadata operand which is actually is a constant expression which should be lowered, for example constant expression metadata can appear as operand of debug instruction. --- lib/SPIRV/SPIRVLowerConstExpr.cpp | 15 ++++++- test/lshr-constexpr.ll | 65 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/lshr-constexpr.ll diff --git a/lib/SPIRV/SPIRVLowerConstExpr.cpp b/lib/SPIRV/SPIRVLowerConstExpr.cpp index 19fea35167..a5b6c07113 100644 --- a/lib/SPIRV/SPIRVLowerConstExpr.cpp +++ b/lib/SPIRV/SPIRVLowerConstExpr.cpp @@ -170,8 +170,21 @@ void SPIRVLowerConstExpr::visit(Module *M) { } II->replaceUsesOfWith(Op, Repl); WorkList.splice(WorkList.begin(), ReplList); - } else if (auto CE = dyn_cast(Op)) + } else if (auto CE = dyn_cast(Op)) { WorkList.push_front(cast(LowerOp(CE))); + } else if (auto MDAsVal = dyn_cast(Op)) { + Metadata *MD = MDAsVal->getMetadata(); + if (auto ConstMD = dyn_cast(MD)) { + Constant *C = ConstMD->getValue(); + if (auto CE = dyn_cast(C)) { + Value *RepInst = LowerOp(CE); + Metadata *RepMD = ValueAsMetadata::get(RepInst); + Value *RepMDVal = MetadataAsValue::get(M->getContext(), RepMD); + II->setOperand(OI, RepMDVal); + WorkList.push_front(cast(RepInst)); + } + } + } } } } diff --git a/test/lshr-constexpr.ll b/test/lshr-constexpr.ll new file mode 100644 index 0000000000..5e70530b8e --- /dev/null +++ b/test/lshr-constexpr.ll @@ -0,0 +1,65 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: llvm-spirv -r %t.spv -o %from-spirv.bc +; RUN: llvm-dis %from-spirv.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM +; RUN: llvm-spirv --to-text %t.spv -o - | FileCheck %s --check-prefix=CHECK-SPIRV + +; TODO: spirv-val command is not presented here because it fails with error: +; line 29: Invalid source language operand: 12 which is not related to +; functionality that is being checked in this test. + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "spir64-unknown-unknown" + +; CHECK-SPIRV: TypeInt [[type_int32:[0-9]+]] 32 0 +; CHECK-SPIRV: TypeInt [[type_int64:[0-9]+]] 64 0 +; CHECK-SPIRV: Constant [[type_int32]] [[const1:[0-9]+]] 1 +; CHECK-SPIRV: Constant [[type_int64]] [[const32:[0-9]+]] 32 0 +; CHECK-SPIRV: TypeVector [[type_vec:[0-9]+]] [[type_int32]] 2 +; CHECK-SPIRV: ConstantComposite [[type_vec]] [[vec_const:[0-9]+]] [[const1]] [[const1]] + +; CHECK-SPIRV: Bitcast [[type_int64]] [[bitcast_res:[0-9]+]] [[vec_const]] +; CHECK-SPIRV: ShiftRightLogical [[type_int64]] [[shift_res:[0-9]+]] [[bitcast_res]] [[const32]] +; CHECK-SPIRV: DebugValue {{[0-9]+}} [[shift_res]] + +; Function Attrs: nounwind ssp uwtable +define void @foo() #0 !dbg !4 { +entry: + tail call void @llvm.dbg.value(metadata i64 lshr (i64 bitcast (<2 x i32> to i64), i64 32), metadata !12, metadata !17) #3, !dbg !18 + ret void, !dbg !20 +; CHECK-LLVM: %[[bitcast:[0-9]+]] = bitcast <2 x i32> to i64 +; CHECK-LLVM: %[[shift:[0-9]+]] = lshr i64 %[[bitcast]], 32 +; CHECK-LLVM: call void @llvm.dbg.value(metadata i64 %[[shift]], metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}} +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.value(metadata, metadata, metadata) #2 + +attributes #0 = { nounwind ssp uwtable } +attributes #2 = { nounwind readnone } +attributes #3 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!13, !14, !15} +!llvm.ident = !{!16} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2) +!1 = !DIFile(filename: "t.c", directory: "/path/to/dir") +!2 = !{} +!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{null} +!7 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !8, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11) +!8 = !DISubroutineType(types: !9) +!9 = !{null, !10} +!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !{!12} +!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10) +!13 = !{i32 2, !"Dwarf Version", i32 2} +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = !{i32 1, !"PIC Level", i32 2} +!16 = !{!"clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)"} +!17 = !DIExpression() +!18 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !19) +!19 = distinct !DILocation(line: 4, column: 3, scope: !4) +!20 = !DILocation(line: 6, column: 1, scope: !4) From 35c423ea59a8dadd6ba2c189eef2d6d4abe8354d Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Wed, 21 Oct 2020 17:23:51 +0300 Subject: [PATCH 2/2] [NFC] Re-organize tests a bit (#780) Moved all tests for llvm intrinsics into a separate folder Moved some negative tests into corresponding directory --- test/check_empty_file.ll | 3 - test/{ => llvm-intrinsics}/abs.ll | 0 .../assume.ll} | 0 .../{llvm.ceil.ll => llvm-intrinsics/ceil.ll} | 0 .../constrained-arithmetic.ll} | 0 .../constrained-comparison.ll} | 0 .../constrained-convert.ll} | 0 test/llvm-intrinsics/ctlz.ll | 34 ++++++++++ test/{ => llvm-intrinsics}/ctpop.ll | 0 .../cttz.ll} | 14 ---- .../expect.ll} | 0 .../{llvm.fabs.ll => llvm-intrinsics/fabs.ll} | 0 .../fmuladd.ll} | 0 .../invariant.ll} | 0 .../lifetime.ll | 22 ++++++ test/{ => llvm-intrinsics}/maxnum.ll | 0 .../memcpy.align.ll} | 0 .../memmove.ll} | 0 .../memset.ll} | 0 test/{ => llvm-intrinsics}/nearbyint.ll | 0 .../sadd.with.overflow.ll} | 0 .../{llvm.sqrt.ll => llvm-intrinsics/sqrt.ll} | 0 test/{ => llvm-intrinsics}/trap.ll | 0 .../usub.sat.ll} | 0 test/{ => negative}/InvalidAtomicBuiltins.cl | 0 test/negative/check-empty-file.ll | 3 + .../{empty_file.bc => negative/empty-file.bc} | 0 .../{ => negative}/regularize-invalid-llvm.ll | 0 .../spirv-unknown-extensions.spt | 0 .../spirv-version-controls-1.spt} | 0 .../spirv-version-controls-2.spt} | 0 test/transcoding/lifetime-sized.ll | 68 ------------------- 32 files changed, 59 insertions(+), 85 deletions(-) delete mode 100644 test/check_empty_file.ll rename test/{ => llvm-intrinsics}/abs.ll (100%) rename test/{transcoding/llvm.assume.ll => llvm-intrinsics/assume.ll} (100%) rename test/{llvm.ceil.ll => llvm-intrinsics/ceil.ll} (100%) rename test/{constrained_arifm_intr.ll => llvm-intrinsics/constrained-arithmetic.ll} (100%) rename test/{constrained_cmp_intr.ll => llvm-intrinsics/constrained-comparison.ll} (100%) rename test/{constrained_convert_intr.ll => llvm-intrinsics/constrained-convert.ll} (100%) create mode 100644 test/llvm-intrinsics/ctlz.ll rename test/{ => llvm-intrinsics}/ctpop.ll (100%) rename test/{count-zero-bits.ll => llvm-intrinsics/cttz.ll} (82%) rename test/{transcoding/llvm.expect.ll => llvm-intrinsics/expect.ll} (100%) rename test/{llvm.fabs.ll => llvm-intrinsics/fabs.ll} (100%) rename test/{llvm.fmuladd.ll => llvm-intrinsics/fmuladd.ll} (100%) rename test/{llvm.invariant.ll => llvm-intrinsics/invariant.ll} (100%) rename test/{transcoding => llvm-intrinsics}/lifetime.ll (77%) rename test/{ => llvm-intrinsics}/maxnum.ll (100%) rename test/{transcoding/llvm.memcpy.align.ll => llvm-intrinsics/memcpy.align.ll} (100%) rename test/{transcoding/llvm.memmove.ll => llvm-intrinsics/memmove.ll} (100%) rename test/{transcoding/llvm.memset.ll => llvm-intrinsics/memset.ll} (100%) rename test/{ => llvm-intrinsics}/nearbyint.ll (100%) rename test/{llvm.sadd.with.overflow.ll => llvm-intrinsics/sadd.with.overflow.ll} (100%) rename test/{llvm.sqrt.ll => llvm-intrinsics/sqrt.ll} (100%) rename test/{ => llvm-intrinsics}/trap.ll (100%) rename test/{usub-sat.ll => llvm-intrinsics/usub.sat.ll} (100%) rename test/{ => negative}/InvalidAtomicBuiltins.cl (100%) create mode 100644 test/negative/check-empty-file.ll rename test/{empty_file.bc => negative/empty-file.bc} (100%) rename test/{ => negative}/regularize-invalid-llvm.ll (100%) rename test/{ => negative}/spirv-unknown-extensions.spt (100%) rename test/{spirv-version-controls-negative-1.spt => negative/spirv-version-controls-1.spt} (100%) rename test/{spirv-version-controls-negative-2.spt => negative/spirv-version-controls-2.spt} (100%) delete mode 100644 test/transcoding/lifetime-sized.ll diff --git a/test/check_empty_file.ll b/test/check_empty_file.ll deleted file mode 100644 index 64cf13fa6a..0000000000 --- a/test/check_empty_file.ll +++ /dev/null @@ -1,3 +0,0 @@ -; RUN: not llvm-spirv %S/empty_file.bc -o - 2>&1 | FileCheck %s - -; CHECK: Can't translate, file is empty diff --git a/test/abs.ll b/test/llvm-intrinsics/abs.ll similarity index 100% rename from test/abs.ll rename to test/llvm-intrinsics/abs.ll diff --git a/test/transcoding/llvm.assume.ll b/test/llvm-intrinsics/assume.ll similarity index 100% rename from test/transcoding/llvm.assume.ll rename to test/llvm-intrinsics/assume.ll diff --git a/test/llvm.ceil.ll b/test/llvm-intrinsics/ceil.ll similarity index 100% rename from test/llvm.ceil.ll rename to test/llvm-intrinsics/ceil.ll diff --git a/test/constrained_arifm_intr.ll b/test/llvm-intrinsics/constrained-arithmetic.ll similarity index 100% rename from test/constrained_arifm_intr.ll rename to test/llvm-intrinsics/constrained-arithmetic.ll diff --git a/test/constrained_cmp_intr.ll b/test/llvm-intrinsics/constrained-comparison.ll similarity index 100% rename from test/constrained_cmp_intr.ll rename to test/llvm-intrinsics/constrained-comparison.ll diff --git a/test/constrained_convert_intr.ll b/test/llvm-intrinsics/constrained-convert.ll similarity index 100% rename from test/constrained_convert_intr.ll rename to test/llvm-intrinsics/constrained-convert.ll diff --git a/test/llvm-intrinsics/ctlz.ll b/test/llvm-intrinsics/ctlz.ll new file mode 100644 index 0000000000..ae2a731cbc --- /dev/null +++ b/test/llvm-intrinsics/ctlz.ll @@ -0,0 +1,34 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s +; RUN: llvm-spirv %t.bc -o %t.spv +; RUN: spirv-val %t.spv + +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" +target triple = "spir64-unknown-unknown" + +; CHECK: ExtInstImport [[extinst_id:[0-9]+]] "OpenCL.std" + +; CHECK: Function +; CHECK: 6 ExtInst {{[0-9]+}} {{[0-9]+}} [[extinst_id]] clz +; CHECK: FunctionEnd + +; Function Attrs: nounwind readnone +define spir_func i32 @TestClz(i32 %x) local_unnamed_addr #0 { +entry: + %0 = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) + ret i32 %0 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare i32 @llvm.ctlz.i32(i32, i1 immarg) #1 + +attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.module.flags = !{!0} +!opencl.ocl.version = !{!1} +!opencl.spir.version = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, i32 0} +!2 = !{i32 1, i32 2} diff --git a/test/ctpop.ll b/test/llvm-intrinsics/ctpop.ll similarity index 100% rename from test/ctpop.ll rename to test/llvm-intrinsics/ctpop.ll diff --git a/test/count-zero-bits.ll b/test/llvm-intrinsics/cttz.ll similarity index 82% rename from test/count-zero-bits.ll rename to test/llvm-intrinsics/cttz.ll index 7ed0e58b49..b3eb8637b2 100644 --- a/test/count-zero-bits.ll +++ b/test/llvm-intrinsics/cttz.ll @@ -8,17 +8,6 @@ target triple = "spir64-unknown-unknown" ; CHECK: ExtInstImport [[extinst_id:[0-9]+]] "OpenCL.std" -; CHECK: Function -; CHECK: 6 ExtInst {{[0-9]+}} {{[0-9]+}} [[extinst_id]] clz -; CHECK: FunctionEnd - -; Function Attrs: nounwind readnone -define spir_func i32 @TestClz(i32 %x) local_unnamed_addr #0 { -entry: - %0 = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) - ret i32 %0 -} - ; CHECK: Function ; CHECK: 6 ExtInst {{[0-9]+}} {{[0-9]+}} [[extinst_id]] ctz ; CHECK: FunctionEnd @@ -41,9 +30,6 @@ entry: ret <4 x i32> %0 } -; Function Attrs: nounwind readnone speculatable willreturn -declare i32 @llvm.ctlz.i32(i32, i1 immarg) #1 - ; Function Attrs: nounwind readnone speculatable willreturn declare i32 @llvm.cttz.i32(i32, i1 immarg) #1 diff --git a/test/transcoding/llvm.expect.ll b/test/llvm-intrinsics/expect.ll similarity index 100% rename from test/transcoding/llvm.expect.ll rename to test/llvm-intrinsics/expect.ll diff --git a/test/llvm.fabs.ll b/test/llvm-intrinsics/fabs.ll similarity index 100% rename from test/llvm.fabs.ll rename to test/llvm-intrinsics/fabs.ll diff --git a/test/llvm.fmuladd.ll b/test/llvm-intrinsics/fmuladd.ll similarity index 100% rename from test/llvm.fmuladd.ll rename to test/llvm-intrinsics/fmuladd.ll diff --git a/test/llvm.invariant.ll b/test/llvm-intrinsics/invariant.ll similarity index 100% rename from test/llvm.invariant.ll rename to test/llvm-intrinsics/invariant.ll diff --git a/test/transcoding/lifetime.ll b/test/llvm-intrinsics/lifetime.ll similarity index 77% rename from test/transcoding/lifetime.ll rename to test/llvm-intrinsics/lifetime.ll index f7d86caea1..fc3a6d1787 100644 --- a/test/transcoding/lifetime.ll +++ b/test/llvm-intrinsics/lifetime.ll @@ -19,6 +19,8 @@ target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" target triple = "spir64-unknown-unknown" +%class.anon = type { i8 } + ; Function Attrs: nounwind define spir_kernel void @lifetime_simple(i32 addrspace(1)* nocapture %res, i32 addrspace(1)* nocapture %lhs, i32 addrspace(1)* nocapture %rhs) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !5 !kernel_arg_type_qual !4 { %1 = alloca i32 @@ -40,6 +42,26 @@ define spir_kernel void @lifetime_simple(i32 addrspace(1)* nocapture %res, i32 a ret void } +define spir_kernel void @lifetime_sized() #0 !kernel_arg_addr_space !8 !kernel_arg_access_qual !8 !kernel_arg_type !8 !kernel_arg_base_type !8 !kernel_arg_type_qual !8 { +entry: + %0 = alloca %class.anon, align 1 + %1 = bitcast %class.anon* %0 to i8* + call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #0 + call spir_func void @foo(%class.anon* %0) + %2 = bitcast %class.anon* %0 to i8* + call void @llvm.lifetime.end.p0i8(i64 1, i8* %2) #0 + ret void +} + +; Function Attrs: inlinehint nounwind +define internal spir_func void @foo(%class.anon* %this) #0 align 2 { +entry: + %this.addr = alloca %class.anon*, align 8 + store %class.anon* %this, %class.anon** %this.addr, align 8 + %this1 = load %class.anon*, %class.anon** %this.addr, align 8 + ret void +} + ; Function Attrs: nounwind declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0 diff --git a/test/maxnum.ll b/test/llvm-intrinsics/maxnum.ll similarity index 100% rename from test/maxnum.ll rename to test/llvm-intrinsics/maxnum.ll diff --git a/test/transcoding/llvm.memcpy.align.ll b/test/llvm-intrinsics/memcpy.align.ll similarity index 100% rename from test/transcoding/llvm.memcpy.align.ll rename to test/llvm-intrinsics/memcpy.align.ll diff --git a/test/transcoding/llvm.memmove.ll b/test/llvm-intrinsics/memmove.ll similarity index 100% rename from test/transcoding/llvm.memmove.ll rename to test/llvm-intrinsics/memmove.ll diff --git a/test/transcoding/llvm.memset.ll b/test/llvm-intrinsics/memset.ll similarity index 100% rename from test/transcoding/llvm.memset.ll rename to test/llvm-intrinsics/memset.ll diff --git a/test/nearbyint.ll b/test/llvm-intrinsics/nearbyint.ll similarity index 100% rename from test/nearbyint.ll rename to test/llvm-intrinsics/nearbyint.ll diff --git a/test/llvm.sadd.with.overflow.ll b/test/llvm-intrinsics/sadd.with.overflow.ll similarity index 100% rename from test/llvm.sadd.with.overflow.ll rename to test/llvm-intrinsics/sadd.with.overflow.ll diff --git a/test/llvm.sqrt.ll b/test/llvm-intrinsics/sqrt.ll similarity index 100% rename from test/llvm.sqrt.ll rename to test/llvm-intrinsics/sqrt.ll diff --git a/test/trap.ll b/test/llvm-intrinsics/trap.ll similarity index 100% rename from test/trap.ll rename to test/llvm-intrinsics/trap.ll diff --git a/test/usub-sat.ll b/test/llvm-intrinsics/usub.sat.ll similarity index 100% rename from test/usub-sat.ll rename to test/llvm-intrinsics/usub.sat.ll diff --git a/test/InvalidAtomicBuiltins.cl b/test/negative/InvalidAtomicBuiltins.cl similarity index 100% rename from test/InvalidAtomicBuiltins.cl rename to test/negative/InvalidAtomicBuiltins.cl diff --git a/test/negative/check-empty-file.ll b/test/negative/check-empty-file.ll new file mode 100644 index 0000000000..3dca157170 --- /dev/null +++ b/test/negative/check-empty-file.ll @@ -0,0 +1,3 @@ +; RUN: not llvm-spirv %S/empty-file.bc -o - 2>&1 | FileCheck %s + +; CHECK: Can't translate, file is empty diff --git a/test/empty_file.bc b/test/negative/empty-file.bc similarity index 100% rename from test/empty_file.bc rename to test/negative/empty-file.bc diff --git a/test/regularize-invalid-llvm.ll b/test/negative/regularize-invalid-llvm.ll similarity index 100% rename from test/regularize-invalid-llvm.ll rename to test/negative/regularize-invalid-llvm.ll diff --git a/test/spirv-unknown-extensions.spt b/test/negative/spirv-unknown-extensions.spt similarity index 100% rename from test/spirv-unknown-extensions.spt rename to test/negative/spirv-unknown-extensions.spt diff --git a/test/spirv-version-controls-negative-1.spt b/test/negative/spirv-version-controls-1.spt similarity index 100% rename from test/spirv-version-controls-negative-1.spt rename to test/negative/spirv-version-controls-1.spt diff --git a/test/spirv-version-controls-negative-2.spt b/test/negative/spirv-version-controls-2.spt similarity index 100% rename from test/spirv-version-controls-negative-2.spt rename to test/negative/spirv-version-controls-2.spt diff --git a/test/transcoding/lifetime-sized.ll b/test/transcoding/lifetime-sized.ll deleted file mode 100644 index 8a1e203e50..0000000000 --- a/test/transcoding/lifetime-sized.ll +++ /dev/null @@ -1,68 +0,0 @@ -; RUN: llvm-as %s -o %t.bc -; RUN: llvm-spirv %t.bc -spirv-text -o %t.spt -; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV -; RUN: llvm-spirv %t.bc -o %t.spv -; RUN: llvm-spirv -r %t.spv -o %t.bc -; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM - -; CHECK-SPIRV: Variable {{[0-9]+}} [[mem:[0-9]+]] 7 -; CHECK-SPIRV: Bitcast [[i8Ty:[0-9]+]] [[tmp0:[0-9]+]] [[mem]] -; CHECK-SPIRV: LifetimeStart [[tmp0]] [[size:[0-9]+]] -; CHECK-SPIRV: FunctionCall -; CHECK-SPIRV: Bitcast [[i8Ty]] [[tmp1:[0-9]+]] [[mem]] -; CHECK-SPIRV: LifetimeStop [[tmp1]] [[size]] - -; CHECK-LLVM-LABEL: kernel_function -; CHECK-LLVM: [[local:%[0-9]+]] = alloca %class.anon -; CHECK-LLVM: [[tmp1:%[0-9]+]] = bitcast %class.anon* [[local]] to [[type:i[0-9]+\*]] -; CHECK-LLVM: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[tmp1]]) -; CHECK-LLVM: [[tmp2:%[0-9]+]] = bitcast %class.anon* [[local]] to [[type]] -; CHECK-LLVM: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[tmp2]]) - -target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" -target triple = "spir64-unknown-unknown" - -%class.anon = type { i8 } - -define spir_kernel void @kernel_function() #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !3 !kernel_arg_type !3 !kernel_arg_base_type !3 !kernel_arg_type_qual !3 { -entry: - %0 = alloca %class.anon, align 1 - %1 = bitcast %class.anon* %0 to i8* - call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #3 - call spir_func void @foo(%class.anon* %0) - %2 = bitcast %class.anon* %0 to i8* - call void @llvm.lifetime.end.p0i8(i64 1, i8* %2) #3 - ret void -} - -; Function Attrs: argmemonly nounwind -declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1 - -; Function Attrs: inlinehint nounwind -define internal spir_func void @foo(%class.anon* %this) #2 align 2 { -entry: - %this.addr = alloca %class.anon*, align 8 - store %class.anon* %this, %class.anon** %this.addr, align 8 - %this1 = load %class.anon*, %class.anon** %this.addr, align 8 - ret void -} - -; Function Attrs: argmemonly nounwind -declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1 - -attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false -" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { argmemonly nounwind } -attributes #2 = { inlinehint nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no --jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #3 = { nounwind } - -!llvm.module.flags = !{!0} -!opencl.spir.version = !{!1} -!spirv.Source = !{!2} - -!0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 1, i32 2} -!2 = !{i32 4, i32 100000} -!3 = !{} -