|
| 1 | +; RUN: sycl-post-link --ir-output-only -spec-const=default %s -S -o - | \ |
| 2 | +; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-DEF |
| 3 | + |
| 4 | +; This test checks that the post link tool is able to correctly transform |
| 5 | +; specialization constant intrinsics for different types in a device code |
| 6 | +; compiled for AOT. |
| 7 | + |
| 8 | +%class.specialization_id = type { double } |
| 9 | +%class.specialization_id.0 = type { i32 } |
| 10 | +%class.specialization_id.1 = type { %struct.ComposConst } |
| 11 | +%struct.ComposConst = type { i32, double, %struct.myConst } |
| 12 | +%struct.myConst = type { i32, float } |
| 13 | +%class.specialization_id.2 = type { %struct.ComposConst2 } |
| 14 | +%struct.ComposConst2 = type { i8, %struct.myConst, double } |
| 15 | + |
| 16 | +@id_double = dso_local global %class.specialization_id { double 3.140000e+00 }, align 8 |
| 17 | +@id_int = dso_local global %class.specialization_id.0 { i32 42 }, align 4 |
| 18 | +@id_compos = dso_local global %class.specialization_id.1 { %struct.ComposConst { i32 1, double 2.000000e+00, %struct.myConst { i32 13, float 0x4020666660000000 } } }, align 8 |
| 19 | +@id_compos2 = dso_local global %class.specialization_id.2 { %struct.ComposConst2 { i8 1, %struct.myConst { i32 52, float 0x40479999A0000000 }, double 2.000000e+00 } }, align 8 |
| 20 | + |
| 21 | +; check that no longer used globals are removed: |
| 22 | +@__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_doubleE17specialization_idIdEdET1_v = private unnamed_addr constant [37 x i8] c"_ZTS14name_generatorIL_Z9id_doubleEE\00", align 1 |
| 23 | +; CHECK-NOT: @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_doubleE17specialization_idIdEdET1_v |
| 24 | +@__builtin_unique_stable_name._Z27get_specialization_constantIL_Z6id_intE17specialization_idIiEiET1_v = private unnamed_addr constant [34 x i8] c"_ZTS14name_generatorIL_Z6id_intEE\00", align 1 |
| 25 | +; CHECK-NOT: @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z6id_intE17specialization_idIiEiET1_v |
| 26 | +@__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_composE17specialization_idI11ComposConstES1_ET1_v = private unnamed_addr constant [37 x i8] c"_ZTS14name_generatorIL_Z9id_composEE\00", align 1 |
| 27 | +; CHECK-NOT: @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_composE17specialization_idI11ComposConstES1_ET1_v |
| 28 | +@__builtin_unique_stable_name._Z27get_specialization_constantIL_Z10id_compos2E17specialization_idI12ComposConst2ES1_ET1_v = private unnamed_addr constant [39 x i8] c"_ZTS14name_generatorIL_Z10id_compos2EE\00", align 1 |
| 29 | +; CHECK-NOT: @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z10id_compos2E17specialization_idI12ComposConst2ES1_ET1_v |
| 30 | + |
| 31 | +define dso_local void @_Z4testv() local_unnamed_addr #0 { |
| 32 | +entry: |
| 33 | + %call.i = tail call fast double @_Z37__sycl_getScalar2020SpecConstantValueIdET_PKcPvS3_(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_doubleE17specialization_idIdEdET1_v, i64 0, i64 0), i8* bitcast (%class.specialization_id* @id_double to i8*), i8* null) |
| 34 | +; CHECK-DEF: %[[GEP:[0-9a-z]+]] = getelementptr i8, i8* null, i32 0 |
| 35 | +; CHECK-DEF: %[[BITCAST:[0-9a-z]+]] = bitcast i8* %[[GEP]] to double* |
| 36 | +; CHECK-DEF: %[[LOAD:[0-9a-z]+]] = load double, double* %[[BITCAST]], align 8 |
| 37 | + %call.i3 = tail call i32 @_Z37__sycl_getScalar2020SpecConstantValueIiET_PKcPvS3_(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z6id_intE17specialization_idIiEiET1_v, i64 0, i64 0), i8* bitcast (%class.specialization_id.0* @id_int to i8*), i8* null) |
| 38 | +; CHECK-DEF: %[[GEP1:[0-9a-z]+]] = getelementptr i8, i8* null, i32 8 |
| 39 | +; CHECK-DEF: %[[BITCAST1:[0-9a-z]+]] = bitcast i8* %[[GEP1]] to i32* |
| 40 | +; CHECK-DEF: %[[LOAD1:[0-9a-z]+]] = load i32, i32* %[[BITCAST1]], align 4 |
| 41 | + %call.i4 = tail call fast double @_Z37__sycl_getScalar2020SpecConstantValueIdET_PKcPvS3_(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_doubleE17specialization_idIdEdET1_v, i64 0, i64 0), i8* bitcast (%class.specialization_id* @id_double to i8*), i8* null) |
| 42 | +; CHECK-DEF: %[[GEP2:[0-9a-z]+]] = getelementptr i8, i8* null, i32 0 |
| 43 | +; CHECK-DEF: %[[BITCAST2:[0-9a-z]+]] = bitcast i8* %[[GEP2]] to double* |
| 44 | +; CHECK-DEF: %[[LOAD2:[0-9a-z]+]] = load double, double* %[[BITCAST2]], align 8 |
| 45 | + ret void |
| 46 | +} |
| 47 | + |
| 48 | +define dso_local void @_Z5test2v() local_unnamed_addr #0 { |
| 49 | +entry: |
| 50 | + %tmp = alloca %struct.ComposConst, align 8 |
| 51 | + %tmp1 = alloca %struct.ComposConst2, align 8 |
| 52 | + %tmp2 = alloca %struct.ComposConst, align 8 |
| 53 | + %0 = bitcast %struct.ComposConst* %tmp to i8* |
| 54 | + call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %0) #3 |
| 55 | + call void @_Z40__sycl_getComposite2020SpecConstantValueI11ComposConstET_PKcPvS4_(%struct.ComposConst* nonnull sret(%struct.ComposConst) align 8 %tmp, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_composE17specialization_idI11ComposConstES1_ET1_v, i64 0, i64 0), i8* bitcast (%class.specialization_id.1* @id_compos to i8*), i8* null) |
| 56 | +; CHECK: %[[GEP:[0-9a-z]+]] = getelementptr i8, i8* null, i32 12 |
| 57 | +; CHECK: %[[BITCAST:[0-9a-z]+]] = bitcast i8* %[[GEP]] to %struct.ComposConst* |
| 58 | +; CHECK: %[[LOAD:[0-9a-z]+]] = load %struct.ComposConst, %struct.ComposConst* %[[BITCAST]], align 8 |
| 59 | +; CHECK: store %struct.ComposConst %[[LOAD]], %struct.ComposConst* |
| 60 | + call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %0) #3 |
| 61 | + %1 = getelementptr inbounds %struct.ComposConst2, %struct.ComposConst2* %tmp1, i64 0, i32 0 |
| 62 | + call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %1) #3 |
| 63 | + call void @_Z40__sycl_getComposite2020SpecConstantValueI12ComposConst2ET_PKcPvS4_(%struct.ComposConst2* nonnull sret(%struct.ComposConst2) align 8 %tmp1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z10id_compos2E17specialization_idI12ComposConst2ES1_ET1_v, i64 0, i64 0), i8* getelementptr inbounds (%class.specialization_id.2, %class.specialization_id.2* @id_compos2, i64 0, i32 0, i32 0), i8* null) call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #3 |
| 64 | +; CHECK: %[[GEP1:[0-9a-z]+]] = getelementptr i8, i8* null, i32 36 |
| 65 | +; CHECK: %[[BITCAST1:[0-9a-z]+]] = bitcast i8* %[[GEP1]] to %struct.ComposConst2* |
| 66 | +; CHECK: %[[LOAD1:[0-9a-z]+]] = load %struct.ComposConst2, %struct.ComposConst2* %[[BITCAST1]], align 8 |
| 67 | +; CHECK: store %struct.ComposConst2 %[[LOAD1]], %struct.ComposConst2* |
| 68 | + %2 = bitcast %struct.ComposConst* %tmp2 to i8* |
| 69 | + call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %2) #3 |
| 70 | + call void @_Z40__sycl_getComposite2020SpecConstantValueI11ComposConstET_PKcPvS4_(%struct.ComposConst* nonnull sret(%struct.ComposConst) align 8 %tmp2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @__builtin_unique_stable_name._Z27get_specialization_constantIL_Z9id_composE17specialization_idI11ComposConstES1_ET1_v, i64 0, i64 0), i8* bitcast (%class.specialization_id.1* @id_compos to i8*), i8* null) |
| 71 | +; CHECK: %[[GEP2:[0-9a-z]+]] = getelementptr i8, i8* null, i32 12 |
| 72 | +; CHECK: %[[BITCAST2:[0-9a-z]+]] = bitcast i8* %[[GEP2]] to %struct.ComposConst* |
| 73 | +; CHECK: %[[LOAD2:[0-9a-z]+]] = load %struct.ComposConst, %struct.ComposConst* %[[BITCAST2]], align 8 |
| 74 | +; CHECK: store %struct.ComposConst %[[LOAD2]], %struct.ComposConst* |
| 75 | + call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %2) #3 |
| 76 | + ret void |
| 77 | +} |
| 78 | +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 |
| 79 | + |
| 80 | +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 |
| 81 | + |
| 82 | +declare dso_local double @_Z37__sycl_getScalar2020SpecConstantValueIdET_PKcPvS3_(i8*, i8*, i8*) local_unnamed_addr #1 |
| 83 | + |
| 84 | +declare dso_local i32 @_Z37__sycl_getScalar2020SpecConstantValueIiET_PKcPvS3_(i8*, i8*, i8*) local_unnamed_addr #1 |
| 85 | + |
| 86 | +declare dso_local void @_Z40__sycl_getComposite2020SpecConstantValueI11ComposConstET_PKcPvS4_(%struct.ComposConst* sret(%struct.ComposConst) align 8, i8*, i8*, i8*) local_unnamed_addr #2 |
| 87 | + |
| 88 | +declare dso_local void @_Z40__sycl_getComposite2020SpecConstantValueI12ComposConst2ET_PKcPvS4_(%struct.ComposConst2* sret(%struct.ComposConst2) align 8, i8*, i8*, i8*) local_unnamed_addr #2 |
| 89 | + |
| 90 | +attributes #0 = { uwtable mustprogress "denormal-fp-math"="preserve-sign,preserve-sign" "denormal-fp-math-f32"="ieee,ieee" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="true" "no-jump-tables"="false" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="true" "use-soft-float"="false" } |
| 91 | +attributes #1 = { argmemonly nofree nosync nounwind willreturn } |
| 92 | +attributes #2 = { "denormal-fp-math"="preserve-sign,preserve-sign" "denormal-fp-math-f32"="ieee,ieee" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="true" "use-soft-float"="false" } |
| 93 | +attributes #3 = { nounwind } |
0 commit comments