Skip to content

Commit 626d6f4

Browse files
vmaksimoagainull
authored andcommitted
Support translation of DebugEntryPoint instruction (intel#1973)
This instruction is generated for DWARF `DISPFlagMainSubprogram` flag of function as well as for `spir_kernel` functions. Spec: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/nonsemantic/NonSemantic.Shader.DebugInfo.100.asciidoc#DebugEntryPoint Original commit: KhronosGroup/SPIRV-LLVM-Translator@8565381
1 parent 5853474 commit 626d6f4

File tree

10 files changed

+152
-30
lines changed

10 files changed

+152
-30
lines changed

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
11441144

11451145
SPIRVEntry *DebugFunc = nullptr;
11461146
SPIRVValue *FuncDef = nullptr;
1147+
bool IsEntryPointKernel = false;
11471148
if (!Func->isDefinition()) {
11481149
DebugFunc =
11491150
BM->addDebugInfo(SPIRVDebug::FunctionDeclaration, getVoidTy(), Ops);
@@ -1158,11 +1159,30 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
11581159
Ops[FunctionIdIdx] = getDebugInfoNoneId();
11591160
for (const llvm::Function &F : M->functions()) {
11601161
if (Func->describes(&F)) {
1162+
// Function definition of spir_kernel can have no "spir_kernel" calling
1163+
// convention because SPIRVRegularizeLLVMBase::addKernelEntryPoint pass
1164+
// could have turned it to spir_func. The "true" entry point is a
1165+
// wrapper kernel function, which can be found further in the module.
1166+
if (FuncDef) {
1167+
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1168+
IsEntryPointKernel = true;
1169+
break;
1170+
}
1171+
continue;
1172+
}
1173+
11611174
SPIRVValue *SPIRVFunc = SPIRVWriter->getTranslatedValue(&F);
11621175
assert(SPIRVFunc && "All function must be already translated");
11631176
Ops[FunctionIdIdx] = SPIRVFunc->getId();
11641177
FuncDef = SPIRVFunc;
1165-
break;
1178+
if (!isNonSemanticDebugInfo())
1179+
break;
1180+
1181+
// Most likely unreachable because of Regularise LLVM pass
1182+
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1183+
IsEntryPointKernel = true;
1184+
break;
1185+
}
11661186
}
11671187
}
11681188
// For NonSemantic.Shader.DebugInfo we store Function Id index as a
@@ -1196,17 +1216,18 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
11961216
DebugFunc = transDbgTemplateParams(TPA, DebugFunc);
11971217
}
11981218

1199-
if (isNonSemanticDebugInfo())
1200-
transDbgFuncDefinition(FuncDef, DebugFunc);
1219+
if (isNonSemanticDebugInfo() &&
1220+
(Func->isMainSubprogram() || IsEntryPointKernel)) [[maybe_unused]]
1221+
SPIRVEntry *Inst = transDbgEntryPoint(Func, DebugFunc);
1222+
1223+
if (isNonSemanticDebugInfo() && FuncDef) [[maybe_unused]]
1224+
SPIRVEntry *Inst = transDbgFuncDefinition(FuncDef, DebugFunc);
12011225

12021226
return DebugFunc;
12031227
}
12041228

12051229
SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFuncDefinition(SPIRVValue *FuncDef,
12061230
SPIRVEntry *DbgFunc) {
1207-
if (!isNonSemanticDebugInfo() || !FuncDef)
1208-
return nullptr;
1209-
12101231
using namespace SPIRVDebug::Operand::FunctionDefinition;
12111232
SPIRVWordVec Ops(OperandCount);
12121233
Ops[FunctionIdx] = DbgFunc->getId();
@@ -1219,6 +1240,31 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFuncDefinition(SPIRVValue *FuncDef,
12191240
Ops, BB, BB->getInst(0));
12201241
}
12211242

1243+
SPIRVEntry *LLVMToSPIRVDbgTran::transDbgEntryPoint(const DISubprogram *Func,
1244+
SPIRVEntry *DbgFunc) {
1245+
using namespace SPIRVDebug::Operand::EntryPoint;
1246+
SPIRVWordVec Ops(OperandCount);
1247+
Ops[EntryPointIdx] = DbgFunc->getId();
1248+
1249+
DICompileUnit *CU = Func->getUnit();
1250+
if (!CU) {
1251+
Ops[CompilationUnitIdx] = SPIRVCUMap.begin()->second->getId();
1252+
SPIRVWord EmptyStrIdx = BM->getString("")->getId();
1253+
Ops[CompilerSignatureIdx] = EmptyStrIdx;
1254+
Ops[CommandLineArgsIdx] = EmptyStrIdx;
1255+
return BM->addDebugInfo(SPIRVDebug::EntryPoint, getVoidTy(), Ops);
1256+
}
1257+
1258+
StringRef Producer = CU->getProducer();
1259+
StringRef Flags = CU->getFlags();
1260+
SPIRVEntry *CUVal = SPIRVCUMap[CU] ? SPIRVCUMap[CU] : getDebugInfoNone();
1261+
1262+
Ops[CompilationUnitIdx] = CUVal->getId();
1263+
Ops[CompilerSignatureIdx] = BM->getString(Producer.str())->getId();
1264+
Ops[CommandLineArgsIdx] = BM->getString(Flags.str())->getId();
1265+
return BM->addDebugInfo(SPIRVDebug::EntryPoint, getVoidTy(), Ops);
1266+
}
1267+
12221268
// Location information
12231269

12241270
SPIRVEntry *LLVMToSPIRVDbgTran::transDbgScope(const DIScope *S) {

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class LLVMToSPIRVDbgTran {
135135
SPIRVEntry *transDbgFunction(const DISubprogram *Func);
136136

137137
SPIRVEntry *transDbgFuncDefinition(SPIRVValue *SPVFunc, SPIRVEntry *DbgFunc);
138+
SPIRVEntry *transDbgEntryPoint(const DISubprogram *Func, SPIRVEntry *DbgFunc);
138139

139140
// Location information
140141
SPIRVEntry *transDbgScope(const DIScope *S);

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,12 +3308,19 @@ bool SPIRVToLLVM::translate() {
33083308
transGlobalCtorDtors(BV);
33093309
}
33103310

3311+
// Entry Points should be translated before all debug intrinsics.
3312+
for (SPIRVExtInst *EI : BM->getDebugInstVec()) {
3313+
if (EI->getExtOp() == SPIRVDebug::EntryPoint)
3314+
DbgTran->transDebugInst(EI);
3315+
}
3316+
33113317
// Compile unit might be needed during translation of debug intrinsics.
33123318
for (SPIRVExtInst *EI : BM->getDebugInstVec()) {
33133319
// Translate Compile Units first.
33143320
if (EI->getExtOp() == SPIRVDebug::CompilationUnit)
33153321
DbgTran->transDebugInst(EI);
33163322
}
3323+
33173324
// Then translate all debug instructions.
33183325
for (SPIRVExtInst *EI : BM->getDebugInstVec()) {
33193326
DbgTran->transDebugInst(EI);

llvm-spirv/lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ DIScope *SPIRVToLLVMDbgTran::getScope(const SPIRVEntry *ScopeInst) {
152152
}
153153

154154
DICompileUnit *
155-
SPIRVToLLVMDbgTran::transCompilationUnit(const SPIRVExtInst *DebugInst) {
155+
SPIRVToLLVMDbgTran::transCompilationUnit(const SPIRVExtInst *DebugInst,
156+
const std::string CompilerVersion,
157+
const std::string Flags) {
158+
// Do nothing in case we have already translated the CU (e.g. during
159+
// DebugEntryPoint translation)
160+
if (BuilderMap[DebugInst->getId()])
161+
return nullptr;
162+
156163
const SPIRVWordVec &Ops = DebugInst->getArguments();
157164

158165
using namespace SPIRVDebug::Operand::CompilationUnit;
@@ -177,18 +184,18 @@ SPIRVToLLVMDbgTran::transCompilationUnit(const SPIRVExtInst *DebugInst) {
177184

178185
if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100) {
179186
return BuilderMap[DebugInst->getId()]->createCompileUnit(
180-
SourceLang, getFile(Ops[SourceIdx]), "spirv", false, "", 0);
187+
SourceLang, getFile(Ops[SourceIdx]), CompilerVersion, false, Flags, 0);
181188
}
182189
if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
183190
StringRef Producer = getString(Ops[ProducerIdx]);
184191
return BuilderMap[DebugInst->getId()]->createCompileUnit(
185-
SourceLang, getFile(Ops[SourceIdx]), Producer, false, "", 0);
192+
SourceLang, getFile(Ops[SourceIdx]), Producer, false, Flags, 0);
186193
}
187194
// TODO: Remove this workaround once we switch to NonSemantic.Shader.* debug
188195
// info by default
189196
auto Producer = findModuleProducer();
190197
return BuilderMap[DebugInst->getId()]->createCompileUnit(
191-
SourceLang, getFile(Ops[SourceIdx]), Producer, false, "", 0);
198+
SourceLang, getFile(Ops[SourceIdx]), Producer, false, Flags, 0);
192199
}
193200

194201
DIBasicType *SPIRVToLLVMDbgTran::transTypeBasic(const SPIRVExtInst *DebugInst) {
@@ -720,7 +727,8 @@ DINode *SPIRVToLLVMDbgTran::transLexicalBlockDiscriminator(
720727
Disc);
721728
}
722729

723-
DINode *SPIRVToLLVMDbgTran::transFunction(const SPIRVExtInst *DebugInst) {
730+
DINode *SPIRVToLLVMDbgTran::transFunction(const SPIRVExtInst *DebugInst,
731+
bool IsMainSubprogram) {
724732
using namespace SPIRVDebug::Operand::Function;
725733
const SPIRVWordVec &Ops = DebugInst->getArguments();
726734
assert(Ops.size() >= MinOperandCount && "Invalid number of operands");
@@ -757,11 +765,13 @@ DINode *SPIRVToLLVMDbgTran::transFunction(const SPIRVExtInst *DebugInst) {
757765
bool IsDefinition = SPIRVDebugFlags & SPIRVDebug::FlagIsDefinition;
758766
bool IsOptimized = SPIRVDebugFlags & SPIRVDebug::FlagIsOptimized;
759767
bool IsLocal = SPIRVDebugFlags & SPIRVDebug::FlagIsLocal;
760-
bool IsMainSubprogram =
768+
bool IsMainSubprogramFlag =
769+
IsMainSubprogram ||
761770
BM->isEntryPoint(spv::ExecutionModelKernel, Ops[FunctionIdIdx]);
762-
DISubprogram::DISPFlags SPFlags =
763-
DISubprogram::toSPFlags(IsLocal, IsDefinition, IsOptimized,
764-
DISubprogram::SPFlagNonvirtual, IsMainSubprogram);
771+
772+
DISubprogram::DISPFlags SPFlags = DISubprogram::toSPFlags(
773+
IsLocal, IsDefinition, IsOptimized, DISubprogram::SPFlagNonvirtual,
774+
IsMainSubprogramFlag);
765775

766776
SPIRVWord ScopeLine =
767777
getConstantValueOrLiteral(Ops, ScopeLineIdx, DebugInst->getExtSetKind());
@@ -911,6 +921,22 @@ DINode *SPIRVToLLVMDbgTran::transFunctionDecl(const SPIRVExtInst *DebugInst) {
911921
return DIS;
912922
}
913923

924+
MDNode *SPIRVToLLVMDbgTran::transEntryPoint(const SPIRVExtInst *DebugInst) {
925+
using namespace SPIRVDebug::Operand::EntryPoint;
926+
const SPIRVWordVec &Ops = DebugInst->getArguments();
927+
assert(Ops.size() == OperandCount && "Invalid number of operands");
928+
929+
SPIRVExtInst *EP = BM->get<SPIRVExtInst>(Ops[EntryPointIdx]);
930+
SPIRVExtInst *CU = BM->get<SPIRVExtInst>(Ops[CompilationUnitIdx]);
931+
std::string Producer = getString(Ops[CompilerSignatureIdx]);
932+
std::string CLArgs = getString(Ops[CommandLineArgsIdx]);
933+
934+
[[maybe_unused]] DICompileUnit *C =
935+
transCompilationUnit(CU, Producer, CLArgs);
936+
937+
return transFunction(EP, true /*IsMainSubprogram*/);
938+
}
939+
914940
MDNode *SPIRVToLLVMDbgTran::transGlobalVariable(const SPIRVExtInst *DebugInst) {
915941
using namespace SPIRVDebug::Operand::GlobalVariable;
916942
const SPIRVWordVec &Ops = DebugInst->getArguments();
@@ -1238,6 +1264,9 @@ MDNode *SPIRVToLLVMDbgTran::transDebugInstImpl(const SPIRVExtInst *DebugInst) {
12381264
case SPIRVDebug::FunctionDefinition:
12391265
return transFunctionDefinition(DebugInst);
12401266

1267+
case SPIRVDebug::EntryPoint:
1268+
return transEntryPoint(DebugInst);
1269+
12411270
case SPIRVDebug::GlobalVariable:
12421271
return transGlobalVariable(DebugInst);
12431272

llvm-spirv/lib/SPIRV/SPIRVToLLVMDbgTran.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class SPIRVToLLVMDbgTran {
103103

104104
MDNode *transDebugInlined(const SPIRVExtInst *Inst);
105105

106-
DICompileUnit *transCompilationUnit(const SPIRVExtInst *DebugInst);
106+
DICompileUnit *transCompilationUnit(const SPIRVExtInst *DebugInst,
107+
const std::string CompilerVersion = "",
108+
const std::string Flags = "");
107109

108110
DIBasicType *transTypeBasic(const SPIRVExtInst *DebugInst);
109111

@@ -141,12 +143,15 @@ class SPIRVToLLVMDbgTran {
141143
DINode *transLexicalBlock(const SPIRVExtInst *DebugInst);
142144
DINode *transLexicalBlockDiscriminator(const SPIRVExtInst *DebugInst);
143145

144-
DINode *transFunction(const SPIRVExtInst *DebugInst);
146+
DINode *transFunction(const SPIRVExtInst *DebugInst,
147+
bool IsMainSubprogram = false);
145148
DINode *transFunctionDefinition(const SPIRVExtInst *DebugInst);
146149
void transFunctionBody(DISubprogram *DIS, SPIRVId FuncId);
147150

148151
DINode *transFunctionDecl(const SPIRVExtInst *DebugInst);
149152

153+
MDNode *transEntryPoint(const SPIRVExtInst *DebugInst);
154+
150155
MDNode *transGlobalVariable(const SPIRVExtInst *DebugInst);
151156

152157
DINode *transLocalVariable(const SPIRVExtInst *DebugInst);

llvm-spirv/lib/SPIRV/libSPIRV/SPIRV.debug.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum Instruction {
5555
ModuleINTEL = 36,
5656
InstCount = 37,
5757
FunctionDefinition = 101,
58+
EntryPoint = 107,
5859
Module = 200,
5960
TypeSubrange = 201,
6061
TypeArrayDynamic = 202,
@@ -552,7 +553,7 @@ enum {
552553
FunctionIdIdx = 9,
553554
DeclarationNonSemIdx = 9,
554555
DeclarationIdx = 10,
555-
// Only for NonSemantic.Schader.DebugInfo.200
556+
// Only for NonSemantic.Shader.DebugInfo.200
556557
TargetFunctionNameIdx = 10,
557558
MinOperandCount = 10
558559
};
@@ -566,6 +567,16 @@ enum {
566567
};
567568
}
568569

570+
namespace EntryPoint {
571+
enum {
572+
EntryPointIdx = 0,
573+
CompilationUnitIdx = 1,
574+
CompilerSignatureIdx = 2,
575+
CommandLineArgsIdx = 3,
576+
OperandCount = 4
577+
};
578+
}
579+
569580
namespace LexicalBlock {
570581
enum {
571582
SourceIdx = 0,
@@ -872,6 +883,9 @@ inline bool hasDbgInstParentScopeIdx(const uint32_t Kind,
872883
case SPIRVDebug::Function:
873884
ParentScopeIdx = Function::ParentIdx;
874885
return true;
886+
case SPIRVDebug::EntryPoint:
887+
ParentScopeIdx = EntryPoint::CompilationUnitIdx;
888+
return true;
875889
case SPIRVDebug::LexicalBlock:
876890
ParentScopeIdx = LexicalBlock::ParentIdx;
877891
return true;

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVExtInst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ template <> inline void SPIRVMap<SPIRVDebugExtOpKind, std::string>::init() {
262262
add(SPIRVDebug::Expression, "DebugExpression");
263263
add(SPIRVDebug::Operation, "DebugOperation");
264264
add(SPIRVDebug::FunctionDefinition, "DebugFunctionDefinition");
265+
add(SPIRVDebug::EntryPoint, "DebugEntryPoint");
265266
}
266267
SPIRV_DEF_NAMEMAP(SPIRVDebugExtOpKind, SPIRVDebugExtOpMap)
267268

llvm-spirv/test/DebugInfo/NonSemantic/DebugFunction.cl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ void kernel k() {
2222
float a = foo(2);
2323
}
2424

25-
// CHECK-SPIRV: String [[foo:[0-9]+]] "foo"
26-
// CHECK-SPIRV: String [[k:[0-9]+]] "k"
27-
// CHECK-SPIRV: [[CU:[0-9]+]] {{[0-9]+}} DebugCompilationUnit
28-
// CHECK-SPIRV: [[#FuncFoo:]] [[#]] DebugFunction [[foo]] {{.*}} [[CU]]
29-
// CHECK-SPIRV: [[#FuncK:]] [[#]] DebugFunction [[k]] {{.*}} [[CU]]
25+
// CHECK-SPIRV-DAG: String [[foo:[0-9]+]] "foo"
26+
// CHECK-SPIRV-DAG: String [[#EmptyStr:]] ""
27+
// CHECK-SPIRV-DAG: String [[k:[0-9]+]] "k"
28+
// CHECK-SPIRV-DAG: String [[#CV:]] "clang version [[#]].0.0 (https://github.com/llvm/llvm-project.git
29+
// CHECK-SPIRV: [[#CU:]] [[#]] DebugCompilationUnit
30+
// CHECK-SPIRV: [[#FuncFoo:]] [[#]] DebugFunction [[foo]] {{.*}} [[#CU]]
31+
// CHECK-SPIRV: [[#FuncK:]] [[#]] DebugFunction [[k]] {{.*}} [[#CU]]
32+
// CHECK-SPIRV: DebugEntryPoint [[#FuncK]] [[#CU]] [[#CV]] [[#EmptyStr]] {{$}}
33+
// CHECK-SPIRV-NOT: DebugEntryPoint
3034
// CHECK-SPIRV-NOT: DebugFunctionDefinition
3135

3236
// CHECK-SPIRV: Function {{[0-9]+}} [[#foo_id:]]
@@ -38,4 +42,6 @@ void kernel k() {
3842
// CHECK-LLVM: define spir_kernel void @k() #{{[0-9]+}} !dbg ![[#k_id:]]
3943

4044
// CHECK-LLVM: ![[#foo_id]] = distinct !DISubprogram(name: "foo"
45+
// CHECK-LLVM-SAME: spFlags: DISPFlagDefinition,
4146
// CHECK-LLVM: ![[#k_id]] = distinct !DISubprogram(name: "k"
47+
// CHECK-LLVM-SAME: spFlags: DISPFlagDefinition | DISPFlagMainSubprogram,

llvm-spirv/test/DebugInfo/NonSemantic/DebugInfoProducer.ll

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,31 @@ attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-
4747

4848
; CHECK-LLVM-200: !DICompileUnit
4949
; CHECK-LLVM-200-SAME: producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
50+
; CHECK-LLVM-200-SAME: flags: "-O2"
5051
; CHECK-LLVM-200-NOT: producer: "spirv"
5152

5253
; CHECK-LLVM-100: !DICompileUnit
53-
; CHECK-LLVM-100-SAME: producer: "spirv"
54-
; CHECK-LLVM-100-NOT: producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
54+
; CHECK-LLVM-100-SAME: producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
55+
; CHECK-LLVM-100-SAME: flags: "-O2"
5556

5657
; CHECK-SPIRV-200: String [[#ProducerId:]] "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
5758
; CHECK-SPIRV-200: DebugCompilationUnit [[#]] [[#]] [[#]] [[#]] [[#ProducerId]]
59+
; CHECK-SPIRV-200: DebugEntryPoint [[#]] [[#]] [[#ProducerId]] [[#]] {{$}}
5860

59-
; CHECK-SPIRV-100-NOT: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
60-
; CHECK-SPIRV-100-NOT: DebugCompilationUnit [[#]] [[#]] [[#]] [[#]] [[#]] {{$}}
61+
; CHECK-SPIRV-100: String [[#ProducerId:]] "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
62+
; CHECK-SPIRV-100-NOT: DebugCompilationUnit [[#]] [[#]] [[#]] [[#]] [[#ProducerId]] {{$}}
63+
; CHECK-SPIRV-100: DebugEntryPoint [[#]] [[#]] [[#ProducerId]] [[#]] {{$}}
6164

6265

63-
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
66+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None, flags: "-O2")
6467
!1 = !DIFile(filename: "<stdin>", directory: "oneAPI")
6568
!2 = !{}
6669
!3 = !{i32 2, !"Debug Info Version", i32 3}
6770
!4 = !{i32 1, !"wchar_size", i32 4}
6871
!5 = !{i32 1, !"ThinLTO", i32 0}
6972
!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
7073
!7 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"}
71-
!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
74+
!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !0, retainedNodes: !2)
7275
!9 = !DIFile(filename: "s.cpp", directory: "C:\\")
7376
!10 = !DISubroutineType(types: !11)
7477
!11 = !{!12}

llvm-spirv/test/DebugInfo/NonSemantic/Shader200/FortranArray.ll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
; RUN: llvm-as %s -o %t.bc
22
; Translation shouldn't crash:
3-
; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-200
3+
; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-200 -o %t.spt
4+
; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
45
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-shader-200
56
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
67
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
78

9+
10+
; CHECK-SPIRV: [[#None:]] [[#]] DebugInfoNone
11+
; CHECK-SPIRV: [[#CompUnit:]] [[#]] DebugCompilationUnit
12+
; CHECK-SPIRV: [[#EntryFunc:]] [[#]] DebugFunction
13+
; CHECK-SPIRV: [[#BaseTy:]] [[#]] DebugTypeBasic
14+
; CHECK-SPIRV: [[#Subrange:]] [[#]] DebugTypeSubrange
15+
; CHECK-SPIRV: DebugTypeArrayDynamic [[#BaseTy]] [[#]] [[#]] [[#None]] [[#None]] [[#Subrange]]
16+
; CHECK-SPIRV: DebugEntryPoint [[#EntryFunc]] [[#CompUnit]] [[#]] [[#]] {{$}}
17+
818
; CHECK-LLVM: !DICompileUnit(language: DW_LANG_Fortran95
919
; CHECK-LLVM: !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#BaseT:]], size: 32, elements: ![[#Elements:]], dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref), associated: !DIExpression(DW_OP_push_object_address, DW_OP_deref, DW_OP_constu, 0, DW_OP_or))
1020
; CHECK-LLVM: ![[#BaseT:]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)

0 commit comments

Comments
 (0)