|
| 1 | +// RUN: %dxc -T lib_6_x -fcgl %s | FileCheck %s --check-prefixes=FCGL,CHECK |
| 2 | +// RUN: %dxc -T lib_6_x -Zi %s | FileCheck %s --check-prefix=DBG |
| 3 | +// RUN: %dxc -T lib_6_x %s | FileCheck %s --check-prefixes=CHECK,DXIL |
| 4 | +// RUN: %dxc -T lib_6_x -Od %s | FileCheck %s --check-prefixes=CHECK,DXIL |
| 5 | + |
| 6 | +// Confirm that linking a shader calling external functions that take node objects as parameters |
| 7 | +// correctly includes the external and internal functions |
| 8 | + |
| 9 | +struct RECORD { |
| 10 | + int X; |
| 11 | +}; |
| 12 | + |
| 13 | +// CHECK: define void @"\01?foo@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* noalias {{(nocapture )?}}sret %agg.result, %"struct.DispatchNodeInputRecord<RECORD>"* {{(nocapture readonly )?}}%input) |
| 14 | +[noinline] |
| 15 | +DispatchNodeInputRecord<RECORD> foo(DispatchNodeInputRecord<RECORD> input) { |
| 16 | +// CHECK: %[[FooLd:.+]] = load %"struct.DispatchNodeInputRecord<RECORD>", %"struct.DispatchNodeInputRecord<RECORD>"* %input |
| 17 | +// CHECK: store %"struct.DispatchNodeInputRecord<RECORD>" %[[FooLd]], %"struct.DispatchNodeInputRecord<RECORD>"* %agg.result |
| 18 | + |
| 19 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %input, metadata ![[FOOINPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"input" !DIExpression() func:"foo" |
| 20 | + return input; |
| 21 | +} |
| 22 | + |
| 23 | +// CHECK: define void @"\01?bar@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* {{(nocapture readonly )?}}%input, %"struct.DispatchNodeInputRecord<RECORD>"* noalias {{(nocapture )?}}%output) |
| 24 | +export |
| 25 | +void bar(DispatchNodeInputRecord<RECORD> input, out DispatchNodeInputRecord<RECORD> output) { |
| 26 | + |
| 27 | +// CHECK: %[[TMP:.+]] = alloca %"struct.DispatchNodeInputRecord<RECORD>"{{(, align 8)?}} |
| 28 | +// CHECK: call void @"\01?foo@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* {{(nonnull |noalias )?}}sret %[[TMP]], %"struct.DispatchNodeInputRecord<RECORD>"* %input) |
| 29 | +// CHECK: %[[BarLd:.+]] = load %"struct.DispatchNodeInputRecord<RECORD>", %"struct.DispatchNodeInputRecord<RECORD>"* %[[TMP]]{{(, align 8)?}} |
| 30 | +// CHECK: store %"struct.DispatchNodeInputRecord<RECORD>" %[[BarLd]], %"struct.DispatchNodeInputRecord<RECORD>"* %output{{(, align 4)?}} |
| 31 | + |
| 32 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %output, metadata ![[BAROUTPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"output" !DIExpression() func:"bar" |
| 33 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %input, metadata ![[BARINPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"input" !DIExpression() func:"bar" |
| 34 | + |
| 35 | + output = foo(input); |
| 36 | +} |
| 37 | + |
| 38 | +// CHECK: define void @"\01?foo2@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* noalias {{(nocapture )?}}sret %agg.result, %"struct.DispatchNodeInputRecord<RECORD>"* {{(nocapture readonly )?}}%input) |
| 39 | +DispatchNodeInputRecord<RECORD> foo2(DispatchNodeInputRecord<RECORD> input) { |
| 40 | +// CHECK: %[[Foo2Ld:.+]] = load %"struct.DispatchNodeInputRecord<RECORD>", %"struct.DispatchNodeInputRecord<RECORD>"* %input{{(, align 4)?}} |
| 41 | +// CHECK: store %"struct.DispatchNodeInputRecord<RECORD>" %[[Foo2Ld]], %"struct.DispatchNodeInputRecord<RECORD>"* %agg.result{{(, align 4)?}} |
| 42 | + |
| 43 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %input, metadata ![[FOO2INPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"input" !DIExpression() func:"foo2" |
| 44 | + |
| 45 | + return input; |
| 46 | +} |
| 47 | + |
| 48 | +// CHECK: define void @"\01?bar2@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* {{(nocapture readonly )?}}%input, %"struct.DispatchNodeInputRecord<RECORD>"* noalias {{(nocapture )?}}%output) |
| 49 | +[noinline] |
| 50 | +export |
| 51 | +void bar2(DispatchNodeInputRecord<RECORD> input, out DispatchNodeInputRecord<RECORD> output) { |
| 52 | +// FCGL: %[[TMP:.+]] = alloca %"struct.DispatchNodeInputRecord<RECORD>", align 4 |
| 53 | +// FCGL: call void @"\01?foo2@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z"(%"struct.DispatchNodeInputRecord<RECORD>"* sret %[[TMP]], %"struct.DispatchNodeInputRecord<RECORD>"* %input) |
| 54 | +// FCGL: %[[Bar2Ld:.+]] = load %"struct.DispatchNodeInputRecord<RECORD>", %"struct.DispatchNodeInputRecord<RECORD>"* %[[TMP]] |
| 55 | +// FCGL: store %"struct.DispatchNodeInputRecord<RECORD>" %[[Bar2Ld]], %"struct.DispatchNodeInputRecord<RECORD>"* %output |
| 56 | + |
| 57 | +// DXIL: %[[Bar2Ld:.+]] = load %"struct.DispatchNodeInputRecord<RECORD>", %"struct.DispatchNodeInputRecord<RECORD>"* %input, {{(align 4, )?}}!noalias |
| 58 | +// DXIL: store %"struct.DispatchNodeInputRecord<RECORD>" %[[Bar2Ld]], %"struct.DispatchNodeInputRecord<RECORD>"* %output{{(, align 4, )?}} |
| 59 | + |
| 60 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %output, metadata ![[BAR2OUTPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"output" !DIExpression() func:"bar2" |
| 61 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %input, metadata ![[BAR2INPUT:[0-9]+]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"input" !DIExpression() func:"bar2" |
| 62 | +// DBG: call void @llvm.dbg.declare(metadata %"struct.DispatchNodeInputRecord<RECORD>"* %input, metadata ![[FOO2INPUT]], metadata !{{[0-9]+}}), !dbg !{{[0-9]+}} ; var:"input" !DIExpression() func:"foo2" |
| 63 | + |
| 64 | + output = foo2(input); |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +// DBG checks debug info to make sure node object types are correctly saved for function parameters and local variable. |
| 69 | +// DBG: ![[Foo:[0-9]+]] = !DISubprogram(name: "foo", linkageName: "\01?foo@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z", scope: !1, file: !1, line: {{[0-9]+}}, type: ![[FooTy:[0-9]+]], isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: void (%"struct.DispatchNodeInputRecord<RECORD>"*, %"struct.DispatchNodeInputRecord<RECORD>"*)* @"\01?foo@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z") |
| 70 | +// DBG: ![[FooTy]] = !DISubroutineType(types: ![[FooTys:[0-9]+]]) |
| 71 | +// DBG: ![[FooTys]] = !{![[ObjTy:[0-9]+]], ![[ObjTy]]} |
| 72 | +// DBG: ![[ObjTy]] = !DICompositeType(tag: DW_TAG_structure_type, name: "DispatchNodeInputRecord<RECORD>", file: !1, size: 32, align: 32, elements: !2, templateParams: ![[TemplateParams:[0-9]+]]) |
| 73 | +// DBG: ![[TemplateParams]] = !{![[TemplateParam:[0-9]+]]} |
| 74 | +// DBG: ![[TemplateParam]] = !DITemplateTypeParameter(name: "recordtype", type: ![[RECORD:[0-9]+]]) |
| 75 | +// DBG: ![[RECORD]] = !DICompositeType(tag: DW_TAG_structure_type, name: "RECORD", file: !1, line: {{[0-9]+}}, size: 32, align: 32, elements: ![[RecordElts:[0-9]+]]) |
| 76 | +// DBG: ![[RecordElts]] = !{![[RecordElt:[0-9]+]]} |
| 77 | +// DBG: ![[RecordElt]] = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: ![[RECORD]], file: !1, line: {{[0-9]+}}, baseType: ![[INT:[0-9]+]], size: 32, align: 32) |
| 78 | +// DBG: ![[INT]] = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 79 | +// DBG: ![[Bar:[0-9]+]] = !DISubprogram(name: "bar", linkageName: "\01?bar@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z", scope: !1, file: !1, line: {{[0-9]+}}, type: ![[BarTy:[0-9]+]], isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: void (%"struct.DispatchNodeInputRecord<RECORD>"*, %"struct.DispatchNodeInputRecord<RECORD>"*)* @"\01?bar@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z") |
| 80 | +// DBG: ![[BarTy]] = !DISubroutineType(types: ![[BarTys:[0-9]+]]) |
| 81 | +// DBG: ![[BarTys]] = !{null, ![[ObjTy]], ![[OutObjTy:[0-9]+]]} |
| 82 | +// DBG: ![[OutObjTy]] = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: ![[ObjTy]]) |
| 83 | +// DBG: ![[Foo2:[0-9]+]] = !DISubprogram(name: "foo2", linkageName: "\01?foo2@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z", scope: !1, file: !1, line: {{[0-9]+}}, type: ![[FooTy]], isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: void (%"struct.DispatchNodeInputRecord<RECORD>"*, %"struct.DispatchNodeInputRecord<RECORD>"*)* @"\01?foo2@@YA?AU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z") |
| 84 | +// DBG: ![[Bar2:[0-9]+]] = !DISubprogram(name: "bar2", linkageName: "\01?bar2@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z", scope: !1, file: !1, line: {{[0-9]+}}, type: ![[BarTy]], isLocal: false, isDefinition: true, scopeLine: {{[0-9]+}}, flags: DIFlagPrototyped, isOptimized: false, function: void (%"struct.DispatchNodeInputRecord<RECORD>"*, %"struct.DispatchNodeInputRecord<RECORD>"*)* @"\01?bar2@@YAXU?$DispatchNodeInputRecord@URECORD@@@@U1@@Z") |
| 85 | +// DBG: ![[FOOINPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "input", arg: 1, scope: ![[Foo]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
| 86 | +// DBG: ![[BAROUTPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "output", arg: 2, scope: ![[Bar]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
| 87 | +// DBG: ![[BARINPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "input", arg: 1, scope: ![[Bar]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
| 88 | +// DBG: ![[FOO2INPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "input", arg: 1, scope: ![[Foo2]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
| 89 | +// DBG: ![[BAR2OUTPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "output", arg: 2, scope: ![[Bar2]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
| 90 | +// DBG: ![[BAR2INPUT]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "input", arg: 1, scope: ![[Bar2]], file: !1, line: {{[0-9]+}}, type: ![[ObjTy]]) |
0 commit comments