1- // RUN: %dxc -E main -T ps_6_0 -HV 2021 %s | FileCheck %s
1+ // RUN: %dxc -E main -T ps_6_0 -fcgl %s | FileCheck %s
2+ // RUN: %dxc -E main -T ps_6_0 -fcgl -Zi -Qembed_debug %s | FileCheck -check-prefixes=CHECK,DI %s
3+
4+ // The goal of this test is to verify the instantiations of `foo` are correctly
5+ // generated _and_ to verify that the correct debug information is generated for
6+ // the instantiations.
27
3- // CHECK:define void @main
48
59template<typename T>
610struct Test {
711
812T t;
913T foo (T t1) {
10- return sin (t) * cos (t1) ;
14+ return t * t1 ;
1115}
1216
1317};
@@ -19,3 +23,53 @@ float2 main(float4 a:A) : SV_Target {
1923 t1.t = a.xy;
2024 return t0.foo (a.y) + t1.foo (a.zw);
2125}
26+
27+
28+ // CHECK: define internal float @"\01?foo@?$Test@{{[A-Z0-9@]+}}"
29+ // CHECK-SAME: (%"struct.Test<float>"* [[this:%.*]], float [[t1:%.*]])
30+
31+ // CHECK: [[t1LocalAddr:%.*]] = alloca float,
32+ // CHECK-NEXT: store float [[t1]], float* [[t1LocalAddr]]
33+
34+ // DI-NEXT: call void @llvm.dbg.declare(metadata float* [[t1LocalAddr]], metadata [[t1FVar:![0-9]+]]
35+ // DI-NEXT: call void @llvm.dbg.declare(metadata %"struct.Test<float>"* [[this]], metadata [[thisFVar:![0-9]+]]
36+
37+ // CHECK-NEXT: [[this_tAddr:%.*]] = getelementptr inbounds %"struct.Test<float>", %"struct.Test<float>"* [[this]], i32 0, i32 0,
38+ // CHECK-NEXT: [[this_t:%.*]] = load float, float* [[this_tAddr]],
39+ // CHECK-NEXT: [[t1Local:%.*]] = load float, float* [[t1LocalAddr]],
40+ // CHECK-NEXT: [[Res:%.*]] = fmul float [[this_t]], [[t1Local]]
41+ // CHECK-NEXT: ret float [[Res]]
42+
43+
44+ // CHECK: define internal <2 x float> @"\01?foo@?$Test@V?$vector{{[A-Za-z0-9@?$]+}}"
45+ // CHECK-SAME: (%"struct.Test<vector<float, 2> >"* [[this:%.*]], <2 x float> [[t1:%.*]])
46+
47+ // CHECK: [[t1LocalAddr:%.*]] = alloca <2 x float>
48+ // CHECK-NEXT: store <2 x float> [[t1]], <2 x float>* [[t1LocalAddr]]
49+
50+ // DI-NEXT: call void @llvm.dbg.declare(metadata <2 x float>* [[t1LocalAddr]], metadata [[t1VVar:![0-9]+]]
51+ // DI-NEXT: call void @llvm.dbg.declare(metadata %"struct.Test<vector<float, 2> >"* [[this]], metadata [[thisVVar:![0-9]+]]
52+
53+ // CHECK-NEXT: [[this_tAddr:%.*]] = getelementptr inbounds %"struct.Test<vector<float, 2> >", %"struct.Test<vector<float, 2> >"* [[this]], i32 0, i32 0
54+ // CHECK-NEXT: [[this_t:%.*]] = load <2 x float>, <2 x float>* [[this_tAddr]]
55+ // CHECK-NEXT: [[t1Local:%.*]] = load <2 x float>, <2 x float>* [[t1LocalAddr]]
56+ // CHECK-NEXT: [[Res:%.*]] = fmul <2 x float> [[this_t]], [[t1Local]]
57+ // CHECK-NEXT ret <2 x float> [[Res]]
58+
59+
60+ // DI: [[DIFile:![0-9]+]] = !DIFile
61+ // DI-DAG: [[DIFloat:![0-9]+]] = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
62+
63+ // DI-DAG: [[FSub:![0-9]+]] = !DISubprogram(name: "foo", linkageName: "\01?foo@?$Test@{{[A-Z@0-9]+}}", scope: [[FloatScope:![0-9]+]], file: [[DIFile]], line: {{[0-9]+}}, type: {{![0-9]+}}, isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: float (%"struct.Test<float>"*, float)* @"\01?foo@?$Test@{{[A-Z@0-9]+}}",
64+ // DI-DAG: [[DITestF:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Test<float>"
65+
66+ // DI-DAG: [[VSub:![0-9]+]] = !DISubprogram(name: "foo", linkageName: "\01?foo@?$Test@V?$vector{{[A-Za-z0-9@?$]+}}", scope: [[VecScope:![0-9]+]], file: [[DIFile]], line: {{[0-9]+}}, type: {{![0-9]+}}, isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: <2 x float> (%"struct.Test<vector<float, 2> >"*, <2 x float>)* @"\01?foo@?$Test@V?$vector{{[A-Za-z0-9@?$]+}}",
67+ // DI-DAG: [[DITestV:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Test<vector<float, 2> >", file: [[DIFile]], line: {{[0-9]+}}, size: 64, align: 32
68+
69+ // DI-DAG: [[t1FVar]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "t1", arg: 2, scope: [[FSub]], file: [[DIFile]], line: {{[0-9]+}}, type: [[DIFloat]])
70+ // DI-DAG: [[thisFVar]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: [[FSub]], type: [[thisFPtr:![0-9]+]])
71+ // DI-DAG: [[thisFPtr]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[DITestF]], size: 32, align: 32)
72+
73+ // DI-DAG: [[t1VVar]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "t1", arg: 2, scope: [[VSub]], file: [[DIFile]]
74+ // DI-DAG: [[thisVVar]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: [[VSub]], type: [[thisVPtr:![0-9]+]])
75+ // DI-DAG: [[thisVPtr]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[DITestV]], size: 32, align: 32)
0 commit comments