Skip to content

Commit afea7f4

Browse files
pratikasharpszymich
authored andcommitted
Propagate storage class attribute from SPIRV to DWARF
Storage class attribute indicates address space being pointed to. This attribute is present in SPIRV binary. The change adds implementation to lower this attribute to llvm IR and then later propagate it to DWARF.
1 parent 26608a0 commit afea7f4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,19 +520,20 @@ class SPIRVToLLVMDbgTran {
520520
OpDebugPtrType ptrType(inst);
521521

522522
auto pointeeType = createType(BM->get<SPIRVExtInst>(ptrType.getBaseType()));
523+
auto storageClass = ptrType.getStorageClass();
523524
auto flags = ptrType.getFlags();
524525

525526
if (flags & SPIRVDebug::Flag::FlagIsLValueReference)
526-
return addMDNode(inst, Builder.createReferenceType(dwarf::DW_TAG_reference_type, pointeeType, M->getDataLayout().getPointerSizeInBits()));
527+
return addMDNode(inst, Builder.createReferenceType(dwarf::DW_TAG_reference_type, pointeeType, M->getDataLayout().getPointerSizeInBits(), 0, storageClass));
527528
else if (flags & SPIRVDebug::Flag::FlagIsRValueReference)
528-
return addMDNode(inst, Builder.createReferenceType(dwarf::DW_TAG_rvalue_reference_type, pointeeType, M->getDataLayout().getPointerSizeInBits()));
529+
return addMDNode(inst, Builder.createReferenceType(dwarf::DW_TAG_rvalue_reference_type, pointeeType, M->getDataLayout().getPointerSizeInBits(), 0, storageClass));
529530
else if (flags & SPIRVDebug::Flag::FlagIsObjectPointer)
530531
{
531-
auto objType = Builder.createPointerType(pointeeType, M->getDataLayout().getPointerSizeInBits());
532+
auto objType = Builder.createPointerType(pointeeType, M->getDataLayout().getPointerSizeInBits(), 0, storageClass);
532533
return addMDNode(inst, Builder.createObjectPointerType(objType));
533534
}
534535
else
535-
return addMDNode(inst, Builder.createPointerType(pointeeType, M->getDataLayout().getPointerSizeInBits()));
536+
return addMDNode(inst, Builder.createPointerType(pointeeType, M->getDataLayout().getPointerSizeInBits(),0,storageClass));
536537
}
537538

538539
DIType* createTypeQualifier(SPIRVExtInst* inst)

IGC/DebugInfo/DwarfCompileUnit.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,13 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType *DTy) {
17601760
// Add source line info if available and TyDesc is not a forward declaration.
17611761
if (!DTy->isForwardDecl())
17621762
addSourceLine(&Buffer, DTy);
1763+
1764+
// As per SPIRV spec, storage class value 4 corresponds to WG.
1765+
// We lower this value verbatim in SPIRV translator.
1766+
// So if dwarf address space = 4, mark it as SLM.
1767+
if (operator==(DTy->getDWARFAddressSpace(), 4u)) {
1768+
addUInt(&Buffer, dwarf::DW_AT_address_class, None, 1);
1769+
}
17631770
}
17641771

17651772
/// Return true if the type is appropriately scoped to be contained inside

0 commit comments

Comments
 (0)