SPIRVEntry *
LLVMToSPIRVDbgTran::transDbgImportedEntry(const DIImportedEntity *IE) {
using namespace SPIRVDebug::Operand::ImportedEntity;
- SPIRVWordVec Ops(OperandCount);
auto Tag = static_cast<dwarf::Tag>(IE->getTag());
+ // FIXME: 'OpenCL/bugged' version is kept because it's hard to remove it
+ // It's W/A for missing 2nd index in OpenCL's implementation
+ const SPIRVWord OffsetIdx =
+ isNonSemanticDebugInfo() ? OperandCount - NonSemantic::OperandCount : 0;
+ SPIRVWordVec Ops(OperandCount - OffsetIdx);
Ops[NameIdx] = BM->getString(IE->getName().str())->getId();
Ops[TagIdx] = SPIRV::DbgImportedEntityMap::map(Tag);
- Ops[SourceIdx] = getSource(IE->getFile())->getId();
- Ops[EntityIdx] = transDbgEntry(IE->getEntity())->getId();
- Ops[LineIdx] = IE->getLine();
- Ops[ColumnIdx] = 0; // This version of DIImportedEntity has no column number
- Ops[ParentIdx] = getScope(IE->getScope())->getId();
+ Ops[SourceIdx - OffsetIdx] = getSource(IE->getFile())->getId();
+ Ops[EntityIdx - OffsetIdx] = transDbgEntry(IE->getEntity())->getId();
+ Ops[LineIdx - OffsetIdx] = IE->getLine();
+ // This version of DIImportedEntity has no column number
+ Ops[ColumnIdx - OffsetIdx] = 0;
+ Ops[ParentIdx - OffsetIdx] = getScope(IE->getScope())->getId();
if (isNonSemanticDebugInfo())
- transformToConstant(Ops, {TagIdx, LineIdx, ColumnIdx});
+ transformToConstant(Ops,
+ {TagIdx, LineIdx - OffsetIdx, ColumnIdx - OffsetIdx});
return BM->addDebugInfo(SPIRVDebug::ImportedEntity, getVoidTy(), Ops);
}
DINode *SPIRVToLLVMDbgTran::transImportedEntry(const SPIRVExtInst *DebugInst) {
using namespace SPIRVDebug::Operand::ImportedEntity;
const SPIRVWordVec &Ops = DebugInst->getArguments();
- assert(Ops.size() >= OperandCount && "Invalid number of operands");
- DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
- SPIRVWord Line =
- getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
- DIFile *File = getFile(Ops[SourceIdx]);
- auto *Entity = transDebugInst<DINode>(BM->get<SPIRVExtInst>(Ops[EntityIdx]));
+ // FIXME: 'OpenCL/bugged' version is kept because it's hard to remove it
+ // It's W/A for missing 2nd index in OpenCL's implementation
+ const SPIRVWord OffsetIdx = isNonSemanticDebugInfo(DebugInst->getExtSetKind())
+ ? OperandCount - NonSemantic::OperandCount
+ : 0;
+
+ assert(Ops.size() == (OperandCount - OffsetIdx) &&
+ "Invalid number of operands");
+ DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx - OffsetIdx]));
+ SPIRVWord Line = getConstantValueOrLiteral(Ops, LineIdx - OffsetIdx,
+ DebugInst->getExtSetKind());
+ DIFile *File = getFile(Ops[SourceIdx - OffsetIdx]);
+ auto *Entity =
+ transDebugInst<DINode>(BM->get<SPIRVExtInst>(Ops[EntityIdx - OffsetIdx]));
SPIRVWord Tag =
getConstantValueOrLiteral(Ops, TagIdx, DebugInst->getExtSetKind());
if (Tag == SPIRVDebug::ImportedModule) {
return getDIBuilder(DebugInst).createImportedDeclaration(Scope, Entity,
File, Line, Name);
}
- // FIXME: uncomment and fix following line, with existing bugs it's reachable.
- // llvm_unreachable("Unexpected kind of imported entity!");
- // Imported entity translation is broken. For example ImportedEntity is
- // missing 2nd parameter.
- return nullptr;
+ llvm_unreachable("Unexpected kind of imported entity!");
}
DINode *SPIRVToLLVMDbgTran::transModule(const SPIRVExtInst *DebugInst) {
}
namespace ImportedEntity {
+inline namespace OpenCL {
+// it's bugged version, note 2nd index is missing
+// FIXME: need to remove it after some graceful period
enum {
NameIdx = 0,
TagIdx = 1,
ParentIdx = 7,
OperandCount = 8
};
-}
+} // namespace OpenCL
+namespace NonSemantic {
+enum {
+ NameIdx = 0,
+ TagIdx = 1,
+ SourceIdx = 2,
+ EntityIdx = 3,
+ LineIdx = 4,
+ ColumnIdx = 5,
+ ParentIdx = 6,
+ OperandCount = 7
+};
+} // namespace NonSemantic
+} // namespace ImportedEntity
namespace ModuleINTEL {
enum {
; CHECK-SPIRV: ExtInst [[#]] [[#Parent:]] [[#]] DebugCompilationUnit [[#Version]] [[#DWARF]]
; CHECK-SPIRV: ExtInst [[#]] [[#SourceEmpty:]] [[#]] DebugSource [[#EmptyStr]]
; CHECK-SPIRV: ExtInst [[#]] [[#Module:]] [[#]] DebugModule [[#Name]] [[#SourceEmpty]] [[#Constant0]] [[#Parent]] [[#Defines]] [[#IncludePath]] [[#ApiNotes]] [[#Constant0]]
-; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugImportedEntity [[#]] [[#]] [[#]] [[#Source]] [[#Module]]
+; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugImportedEntity [[#]] [[#]] [[#Source]] [[#Module]]
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!6, !7}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !6)
!6 = !{!7}
-!7 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !8, entity: !8, file: !1, line: 3)
+!7 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !8, entity: !11, file: !1, line: 3)
!8 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !5, retainedNodes: !2)
!9 = !DISubroutineType(types: !10)
!10 = !{null}