From 4d5acb8321adae39788d08b903e8003e1c044ef2 Mon Sep 17 00:00:00 2001 From: LU-JOHN <111294400+LU-JOHN@users.noreply.github.com> Date: Fri, 9 Jun 2023 07:05:17 -0500 Subject: [PATCH] [PATCH 60/79] Implement DebugLine and DebugNoLine (#2012) Implement DebugLine/DebugNoLine for NonSemantic.Shader.DebugInfo.100 and NonSemantic.Shader.DebugInfo.200. Updated test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll to test these changes. Gbp-Pq: Name 0060-Implement-DebugLine-and-DebugNoLine-2012.patch --- lib/SPIRV/LLVMToSPIRVDbgTran.cpp | 12 ++- lib/SPIRV/SPIRVToLLVMDbgTran.cpp | 11 ++- lib/SPIRV/libSPIRV/SPIRV.debug.h | 19 ++++ lib/SPIRV/libSPIRV/SPIRVEntry.cpp | 44 ++++++++- lib/SPIRV/libSPIRV/SPIRVEntry.h | 4 + lib/SPIRV/libSPIRV/SPIRVExtInst.h | 2 + lib/SPIRV/libSPIRV/SPIRVFunction.cpp | 14 ++- lib/SPIRV/libSPIRV/SPIRVModule.cpp | 76 +++++++++++++++- lib/SPIRV/libSPIRV/SPIRVModule.h | 10 +++ lib/SPIRV/libSPIRV/SPIRVStream.cpp | 12 +++ .../Shader200/DebugInfoStringType.ll | 43 +++++++-- .../Shader200/DebugInfoSubrange.ll | 24 ++++- .../Shader200/DebugInfoTargetFunction.ll | 21 ++++- .../Shader200/DebugLinePriority.spt | 89 +++++++++++++++++++ 14 files changed, 363 insertions(+), 18 deletions(-) create mode 100644 test/DebugInfo/NonSemantic/Shader200/DebugLinePriority.spt diff --git a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp index 757fd8e..d3daa26 100644 --- a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp +++ b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp @@ -233,8 +233,16 @@ void LLVMToSPIRVDbgTran::transLocationInfo() { V = VPrev; } } - BM->addLine(V, File ? File->getId() : getDebugInfoNone()->getId(), - LineNo, Col); + if (BM->getDebugInfoEIS() == + SPIRVEIS_NonSemantic_Shader_DebugInfo_100 || + BM->getDebugInfoEIS() == + SPIRVEIS_NonSemantic_Shader_DebugInfo_200) + BM->addDebugLine(V, getVoidTy(), + File ? File->getId() : getDebugInfoNoneId(), + LineNo, LineNo, Col, Col + 1); + else + BM->addLine(V, File ? File->getId() : getDebugInfoNoneId(), LineNo, + Col); } } // Instructions } // Basic Blocks diff --git a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp index 42d6924..6fffc4b 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp @@ -1513,7 +1513,16 @@ DebugLoc SPIRVToLLVMDbgTran::transDebugScope(const SPIRVInstruction *Inst) { unsigned Col = 0; MDNode *Scope = nullptr; MDNode *InlinedAt = nullptr; - if (auto L = Inst->getLine()) { + + // If DebugLine and OpLine are both active give DebugLine priority + if (auto DL = Inst->getDebugLine()) { + using namespace SPIRVDebug::Operand::DebugLine; + SPIRVWordVec DebugLineArgs = DL->getArguments(); + Line = + getConstantValueOrLiteral(DebugLineArgs, StartIdx, DL->getExtSetKind()); + Col = getConstantValueOrLiteral(DebugLineArgs, ColumnStartIdx, + DL->getExtSetKind()); + } else if (auto L = Inst->getLine()) { Line = L->getLine(); Col = L->getColumn(); } diff --git a/lib/SPIRV/libSPIRV/SPIRV.debug.h b/lib/SPIRV/libSPIRV/SPIRV.debug.h index 723a0b1..4f3ce37 100644 --- a/lib/SPIRV/libSPIRV/SPIRV.debug.h +++ b/lib/SPIRV/libSPIRV/SPIRV.debug.h @@ -57,6 +57,8 @@ enum Instruction { InstCount = 37, FunctionDefinition = 101, SourceContinued = 102, + DebugLine = 103, + DebugNoLine = 104, BuildIdentifier = 105, StoragePath = 106, EntryPoint = 107, @@ -627,6 +629,23 @@ enum { }; } +namespace DebugLine { +enum { + SourceIdx = 0, + StartIdx = 1, + EndIdx = 2, + ColumnStartIdx = 3, + ColumnEndIdx = 4, + OperandCount = 5 +}; +} + +namespace DebugNoLine { +enum { + OperandCount = 0 +}; +} + namespace EntryPoint { enum { EntryPointIdx = 0, diff --git a/lib/SPIRV/libSPIRV/SPIRVEntry.cpp b/lib/SPIRV/libSPIRV/SPIRVEntry.cpp index 919567a..5ee1081 100644 --- a/lib/SPIRV/libSPIRV/SPIRVEntry.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVEntry.cpp @@ -175,7 +175,7 @@ void SPIRVEntry::encodeLine(spv_ostream &O) const { if (!Module) return; const std::shared_ptr &CurrLine = Module->getCurrentLine(); - if (Line && ((CurrLine && *Line != *CurrLine) || !CurrLine)) { + if (Line && (!CurrLine || *Line != *CurrLine)) { O << *Line; Module->setCurrentLine(Line); } @@ -183,8 +183,43 @@ void SPIRVEntry::encodeLine(spv_ostream &O) const { Module->setCurrentLine(nullptr); } +namespace { +bool isDebugLineEqual(const SPIRVExtInst &DL1, const SPIRVExtInst &DL2) { + std::vector DL1Args = DL1.getArguments(); + std::vector DL2Args = DL2.getArguments(); + + using namespace SPIRVDebug::Operand::DebugLine; + assert(DL1Args.size() == OperandCount && DL2Args.size() == OperandCount && + "Invalid number of operands"); + return DL1Args[SourceIdx] == DL2Args[SourceIdx] && + DL1Args[StartIdx] == DL2Args[StartIdx] && + DL1Args[EndIdx] == DL2Args[EndIdx] && + DL1Args[ColumnStartIdx] == DL2Args[ColumnStartIdx] && + DL1Args[ColumnEndIdx] == DL2Args[ColumnEndIdx]; +} +} // namespace + +void SPIRVEntry::encodeDebugLine(spv_ostream &O) const { + if (!Module) + return; + const std::shared_ptr &CurrDebugLine = + Module->getCurrentDebugLine(); + if (DebugLine && + (!CurrDebugLine || !isDebugLineEqual(*DebugLine, *CurrDebugLine))) { + O << *DebugLine; + Module->setCurrentDebugLine(DebugLine); + } + if (isEndOfBlock() || + isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100, + SPIRVDebug::DebugNoLine) || + isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200, + SPIRVDebug::DebugNoLine)) + Module->setCurrentDebugLine(nullptr); +} + void SPIRVEntry::encodeAll(spv_ostream &O) const { encodeLine(O); + encodeDebugLine(O); encodeWordCountOpCode(O); encode(O); encodeChildren(O); @@ -301,6 +336,11 @@ void SPIRVEntry::setLine(const std::shared_ptr &L) { SPIRVDBG(if (L) spvdbgs() << "[setLine] " << *L << '\n';) } +void SPIRVEntry::setDebugLine(const std::shared_ptr &DL) { + DebugLine = DL; + SPIRVDBG(if (DL) spvdbgs() << "[setDebugLine] " << *DL << '\n';) +} + void SPIRVEntry::addMemberDecorate(SPIRVMemberDecorate *Dec) { assert(canHaveMemberDecorates() && MemberDecorates.find(Dec->getPair()) == MemberDecorates.end()); @@ -631,8 +671,6 @@ void SPIRVLine::encode(spv_ostream &O) const { void SPIRVLine::decode(std::istream &I) { getDecoder(I) >> FileName >> Line >> Column; - std::shared_ptr L(this); - Module->setCurrentLine(L); } void SPIRVLine::validate() const { diff --git a/lib/SPIRV/libSPIRV/SPIRVEntry.h b/lib/SPIRV/libSPIRV/SPIRVEntry.h index b43cd89..f497c95 100644 --- a/lib/SPIRV/libSPIRV/SPIRVEntry.h +++ b/lib/SPIRV/libSPIRV/SPIRVEntry.h @@ -289,6 +289,7 @@ public: return Id; } std::shared_ptr getLine() const { return Line; } + std::shared_ptr getDebugLine() const { return DebugLine; } SPIRVLinkageTypeKind getLinkageType() const; Op getOpCode() const { return OpCode; } SPIRVModule *getModule() const { return Module; } @@ -358,6 +359,7 @@ public: void setHasNoId() { Attrib |= SPIRVEA_NOID; } void setId(SPIRVId TheId) { Id = TheId; } void setLine(const std::shared_ptr &L); + void setDebugLine(const std::shared_ptr &DL); void setLinkageType(SPIRVLinkageTypeKind); void setModule(SPIRVModule *TheModule); void setName(const std::string &TheName); @@ -384,6 +386,7 @@ public: friend spv_ostream &operator<<(spv_ostream &O, const SPIRVEntry &E); friend std::istream &operator>>(std::istream &I, SPIRVEntry &E); virtual void encodeLine(spv_ostream &O) const; + virtual void encodeDebugLine(spv_ostream &O) const; virtual void encodeAll(spv_ostream &O) const; virtual void encodeName(spv_ostream &O) const; virtual void encodeChildren(spv_ostream &O) const; @@ -448,6 +451,7 @@ protected: DecorateIdMapType DecorateIds; MemberDecorateMapType MemberDecorates; std::shared_ptr Line; + std::shared_ptr DebugLine; }; class SPIRVEntryNoIdGeneric : public SPIRVEntry { diff --git a/lib/SPIRV/libSPIRV/SPIRVExtInst.h b/lib/SPIRV/libSPIRV/SPIRVExtInst.h index 315f73f..e278726 100644 --- a/lib/SPIRV/libSPIRV/SPIRVExtInst.h +++ b/lib/SPIRV/libSPIRV/SPIRVExtInst.h @@ -262,6 +262,8 @@ template <> inline void SPIRVMap::init() { add(SPIRVDebug::Operation, "DebugOperation"); add(SPIRVDebug::FunctionDefinition, "DebugFunctionDefinition"); add(SPIRVDebug::SourceContinued, "DebugSourceContinued"); + add(SPIRVDebug::DebugLine, "DebugLine"); + add(SPIRVDebug::DebugNoLine, "DebugNoLine"); add(SPIRVDebug::EntryPoint, "DebugEntryPoint"); add(SPIRVDebug::BuildIdentifier, "DebugBuildIdentifier"); add(SPIRVDebug::StoragePath, "DebugStoragePath"); diff --git a/lib/SPIRV/libSPIRV/SPIRVFunction.cpp b/lib/SPIRV/libSPIRV/SPIRVFunction.cpp index 8a33929..37698fa 100644 --- a/lib/SPIRV/libSPIRV/SPIRVFunction.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVFunction.cpp @@ -143,7 +143,8 @@ bool SPIRVFunction::decodeBB(SPIRVDecoder &Decoder) { SPIRVEntry *Entry = Decoder.getEntry(); if (Decoder.OpCode == OpLine) { - Module->add(Entry); + std::shared_ptr L(static_cast(Entry)); + Module->setCurrentLine(L); continue; } @@ -159,6 +160,17 @@ bool SPIRVFunction::decodeBB(SPIRVDecoder &Decoder) { assert(Inst); if (Inst->getOpCode() == OpUndef) { Module->add(Inst); + } else if (Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100, + SPIRVDebug::DebugNoLine) || + Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200, + SPIRVDebug::DebugNoLine)) { + continue; + } else if (Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100, + SPIRVDebug::DebugLine) || + Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200, + SPIRVDebug::DebugLine)) { + std::shared_ptr DL(static_cast(Inst)); + Module->setCurrentDebugLine(DL); } else { if (Inst->isExtInst(SPIRVEIS_Debug, SPIRVDebug::Scope) || Inst->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100, SPIRVDebug::Scope) || diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp index dbfcd9f..df64f16 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -186,6 +186,13 @@ public: SPIRVWord Column) override; const std::shared_ptr &getCurrentLine() const override; void setCurrentLine(const std::shared_ptr &Line) override; + void addDebugLine(SPIRVEntry *E, SPIRVType *TheType, SPIRVId FileNameId, + SPIRVWord LineStart, SPIRVWord LineEnd, + SPIRVWord ColumnStart, SPIRVWord ColumnEnd) override; + const std::shared_ptr & + getCurrentDebugLine() const override; + void setCurrentDebugLine( + const std::shared_ptr &DebugLine) override; void addCapability(SPIRVCapabilityKind) override; void addCapabilityInternal(SPIRVCapabilityKind) override; void addExtension(ExtensionID) override; @@ -293,6 +300,8 @@ public: const std::vector &, SPIRVBasicBlock *, SPIRVInstruction * = nullptr) override; + SPIRVEntry *createDebugInfo(SPIRVWord, SPIRVType *TheType, + const std::vector &) override; SPIRVEntry *addDebugInfo(SPIRVWord, SPIRVType *TheType, const std::vector &) override; SPIRVEntry *addModuleProcessed(const std::string &) override; @@ -506,6 +515,7 @@ private: SPIRVStringVec StringVec; SPIRVMemberNameVec MemberNameVec; std::shared_ptr CurrentLine; + std::shared_ptr CurrentDebugLine; SPIRVDecorateVec DecorateVec; SPIRVDecGroupVec DecGroupVec; SPIRVGroupDecVec GroupDecVec; @@ -558,6 +568,60 @@ void SPIRVModuleImpl::addLine(SPIRVEntry *E, SPIRVId FileNameId, SPIRVWord Line, E->setLine(CurrentLine); } +const std::shared_ptr & +SPIRVModuleImpl::getCurrentDebugLine() const { + return CurrentDebugLine; +} + +void SPIRVModuleImpl::setCurrentDebugLine( + const std::shared_ptr &DebugLine) { + CurrentDebugLine = DebugLine; +} + +namespace { +bool isDebugLineEqual(const SPIRVExtInst &CurrentDebugLine, SPIRVId FileNameId, + SPIRVId LineStartId, SPIRVId LineEndId, + SPIRVId ColumnStartId, SPIRVId ColumnEndId) { + assert(CurrentDebugLine.getExtOp() == SPIRVDebug::DebugLine); + const std::vector CurrentDebugLineArgs = + CurrentDebugLine.getArguments(); + + using namespace SPIRVDebug::Operand::DebugLine; + return CurrentDebugLineArgs[SourceIdx] == FileNameId && + CurrentDebugLineArgs[StartIdx] == LineStartId && + CurrentDebugLineArgs[EndIdx] == LineEndId && + CurrentDebugLineArgs[ColumnStartIdx] == ColumnStartId && + CurrentDebugLineArgs[ColumnEndIdx] == ColumnEndId; +} +} // namespace + +void SPIRVModuleImpl::addDebugLine(SPIRVEntry *E, SPIRVType *TheType, + SPIRVId FileNameId, SPIRVWord LineStart, + SPIRVWord LineEnd, SPIRVWord ColumnStart, + SPIRVWord ColumnEnd) { + if (!(CurrentDebugLine && + isDebugLineEqual(*CurrentDebugLine, FileNameId, + getLiteralAsConstant(LineStart)->getId(), + getLiteralAsConstant(LineEnd)->getId(), + getLiteralAsConstant(ColumnStart)->getId(), + getLiteralAsConstant(ColumnEnd)->getId()))) { + using namespace SPIRVDebug::Operand::DebugLine; + + std::vector DebugLineOps(OperandCount); + DebugLineOps[SourceIdx] = FileNameId; + DebugLineOps[StartIdx] = getLiteralAsConstant(LineStart)->getId(); + DebugLineOps[EndIdx] = getLiteralAsConstant(LineEnd)->getId(); + DebugLineOps[ColumnStartIdx] = getLiteralAsConstant(ColumnStart)->getId(); + DebugLineOps[ColumnEndIdx] = getLiteralAsConstant(ColumnEnd)->getId(); + + CurrentDebugLine.reset(static_cast( + createDebugInfo(SPIRVDebug::DebugLine, TheType, DebugLineOps))); + } + + assert(E && "invalid entry"); + E->setDebugLine(CurrentDebugLine); +} + SPIRVValue *SPIRVModuleImpl::addSamplerConstant(SPIRVType *TheType, SPIRVWord AddrMode, SPIRVWord ParametricMode, @@ -1298,11 +1362,16 @@ SPIRVInstruction *SPIRVModuleImpl::addExtInst( InsertBefore); } +SPIRVEntry * +SPIRVModuleImpl::createDebugInfo(SPIRVWord InstId, SPIRVType *TheType, + const std::vector &Args) { + return new SPIRVExtInst(this, getId(), TheType, SPIRVEIS_OpenCL_DebugInfo_100, + ExtInstSetIds[getDebugInfoEIS()], InstId, Args); +} + SPIRVEntry *SPIRVModuleImpl::addDebugInfo(SPIRVWord InstId, SPIRVType *TheType, const std::vector &Args) { - return addEntry( - new SPIRVExtInst(this, getId(), TheType, SPIRVEIS_OpenCL_DebugInfo_100, - ExtInstSetIds[getDebugInfoEIS()], InstId, Args)); + return addEntry(createDebugInfo(InstId, TheType, Args)); } SPIRVEntry *SPIRVModuleImpl::addModuleProcessed(const std::string &Process) { @@ -1825,6 +1894,7 @@ spv_ostream &operator<<(spv_ostream &O, SPIRVModule &M) { SPIRVModuleImpl &MI = *static_cast(&M); // Start tracking of the current line with no line MI.CurrentLine.reset(); + MI.CurrentDebugLine.reset(); SPIRVEncoder Encoder(O); Encoder << MagicNumber << MI.SPIRVVersion diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.h b/lib/SPIRV/libSPIRV/SPIRVModule.h index 0241f91..b7a09cf 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.h +++ b/lib/SPIRV/libSPIRV/SPIRVModule.h @@ -198,6 +198,14 @@ public: SPIRVWord Column) = 0; virtual const std::shared_ptr &getCurrentLine() const = 0; virtual void setCurrentLine(const std::shared_ptr &) = 0; + virtual void addDebugLine(SPIRVEntry *E, SPIRVType *TheType, + SPIRVId FileNameId, SPIRVWord LineStart, + SPIRVWord LineEnd, SPIRVWord ColumnStart, + SPIRVWord ColumnEnd) = 0; + virtual const std::shared_ptr & + getCurrentDebugLine() const = 0; + virtual void + setCurrentDebugLine(const std::shared_ptr &) = 0; virtual const SPIRVDecorateGeneric *addDecorate(SPIRVDecorateGeneric *) = 0; virtual SPIRVDecorationGroup *addDecorationGroup() = 0; virtual SPIRVDecorationGroup * @@ -307,6 +315,8 @@ public: const std::vector &, SPIRVBasicBlock *, SPIRVInstruction * = nullptr) = 0; + virtual SPIRVEntry *createDebugInfo(SPIRVWord, SPIRVType *, + const std::vector &) = 0; virtual SPIRVEntry *addDebugInfo(SPIRVWord, SPIRVType *, const std::vector &) = 0; virtual SPIRVEntry *addModuleProcessed(const std::string &) = 0; diff --git a/lib/SPIRV/libSPIRV/SPIRVStream.cpp b/lib/SPIRV/libSPIRV/SPIRVStream.cpp index 18fef3d..b30dbe2 100644 --- a/lib/SPIRV/libSPIRV/SPIRVStream.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVStream.cpp @@ -245,9 +245,21 @@ SPIRVEntry *SPIRVDecoder::getEntry() { Entry->setWordCount(WordCount); if (OpCode != OpLine) Entry->setLine(M.getCurrentLine()); + if (!Entry->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100, + SPIRVDebug::DebugLine) && + !Entry->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200, + SPIRVDebug::DebugLine)) + Entry->setDebugLine(M.getCurrentDebugLine()); + IS >> *Entry; if (Entry->isEndOfBlock() || OpCode == OpNoLine) M.setCurrentLine(nullptr); + if (Entry->isEndOfBlock() || + Entry->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100, + SPIRVDebug::DebugNoLine) || + Entry->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200, + SPIRVDebug::DebugNoLine)) + M.setCurrentDebugLine(nullptr); if (OpExtension == OpCode) { auto *OpExt = static_cast(Entry); diff --git a/test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll b/test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll index 7b82c1d..5506128 100644 --- a/test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll +++ b/test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll @@ -13,8 +13,20 @@ ; CHECK-SPIRV: String [[#StrChar2:]] "CHARACTER_2" ; CHECK-SPIRV: String [[#StrChar3:]] "CHARACTER_3" ; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 0 -; CHECK-SPIRV: Constant [[#TypeInt]] [[#ConstZero:]] 0 -; CHECK-SPIRV: Constant [[#TypeInt]] [[#Const80:]] 80 +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#ConstZero:]] 0{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const1:]] 1{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const2:]] 2{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const6:]] 6{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const7:]] 7{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const9:]] 9{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const12:]] 12{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const23:]] 23{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const24:]] 24{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const27:]] 27{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const28:]] 28{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const36:]] 36{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const37:]] 37{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const80:]] 80{{[[:space:]]}} ; CHECK-SPIRV: TypeVoid [[#TypeVoid:]] ; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone @@ -32,14 +44,33 @@ ; CHECK-SPIRV-COUNT-4: [[#LengthAddrVar2:]] [[#EISId]] DebugLocalVariable ; CHECK-SPIRV-NEXT: [[#EISId]] DebugTypeString [[#StrChar2]] [[#DINoneId]] [[#DINoneId]] [[#ConstZero]] [[#LengthAddrVar2]] -; CHECK-LLVM: !DICompileUnit(language: DW_LANG_Fortran95 +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const6]] [[#Const6]] [[#Const23]] [[#Const24]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#ConstZero]] [[#ConstZero]] [[#ConstZero]] [[#Const1]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const9]] [[#Const9]] [[#Const27]] [[#Const28]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const9]] [[#Const9]] [[#Const36]] [[#Const37]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const7]] [[#Const7]] [[#Const1]] [[#Const2]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#ConstZero]] [[#ConstZero]] [[#ConstZero]] [[#Const1]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const9]] [[#Const9]] [[#Const27]] [[#Const28]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const9]] [[#Const9]] [[#Const36]] [[#Const37]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Const12]] [[#Const12]] [[#Const1]] [[#Const2]] + +; CHECK-LLVM-DAG: !DICompileUnit(language: DW_LANG_Fortran95 +; CHECK-LLVM-DAG: ![[#Scope_hello_world:]] = distinct !DISubprogram(name: "hello_world", linkageName: "MAIN__" +; CHECK-LLVM-DAG: !DILocation(line: 6, column: 23, scope: ![[#Scope_hello_world]] ; CHECK-LLVM-DAG: !DIStringType(name: "CHARACTER_1", size: 80) ; CHECK-LLVM-DAG: !DIStringType(name: ".str.GREETING", stringLengthExpression: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8), stringLocationExpression: !DIExpression(DW_OP_push_object_address, DW_OP_deref)) -; CHECK-LLVM-DAG: ![[#Scope:]] = distinct !DISubprogram(name: "print_greeting", linkageName: "print_greeting_" -; CHECK-LLVM-DAG: ![[#StrLenMD:]] = !DILocalVariable(name: "STRING1.len", scope: ![[#Scope]] +; CHECK-LLVM-DAG: ![[#Scope_print_greeting:]] = distinct !DISubprogram(name: "print_greeting", linkageName: "print_greeting_" +; CHECK-LLVM-DAG: ![[#StrLenMD:]] = !DILocalVariable(name: "STRING1.len", scope: ![[#Scope_print_greeting]] ; CHECK-LLVM-DAG: !DIStringType(name: "CHARACTER_2", stringLength: ![[#StrLenMD]]) -; CHECK-LLVM-DAG: ![[#StrLenMD1:]] = !DILocalVariable(name: "STRING2.len", scope: ![[#Scope]] +; CHECK-LLVM-DAG: ![[#StrLenMD1:]] = !DILocalVariable(name: "STRING2.len", scope: ![[#Scope_print_greeting]] ; CHECK-LLVM-DAG: !DIStringType(name: "CHARACTER_3", stringLength: ![[#StrLenMD1]]) +; CHECK-LLVM: !DILocation(line: 9, column: 27, scope: ![[#Scope_print_greeting]] +; CHECK-LLVM-NEXT: !DILocation(line: 9, column: 36, scope: ![[#Scope_print_greeting]] +; CHECK-LLVM-NEXT: !DILocation(line: 7, column: 1, scope: ![[#Scope_hello_world]] +; CHECK-LLVM-NEXT: !DILocation(line: 0, scope: ![[#Scope_print_greeting]] +; CHECK-LLVM-NEXT: !DILocation(line: 9, column: 27, scope: ![[#Scope_print_greeting]] +; CHECK-LLVM-NEXT: !DILocation(line: 9, column: 36, scope: ![[#Scope_print_greeting]] +; CHECK-LLVM-NEXT: !DILocation(line: 12, column: 1, scope: ![[#Scope_print_greeting]] target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "spir64-unknown-unknown" diff --git a/test/DebugInfo/NonSemantic/Shader200/DebugInfoSubrange.ll b/test/DebugInfo/NonSemantic/Shader200/DebugInfoSubrange.ll index 3bb29f0..f3317e0 100644 --- a/test/DebugInfo/NonSemantic/Shader200/DebugInfoSubrange.ll +++ b/test/DebugInfo/NonSemantic/Shader200/DebugInfoSubrange.ll @@ -10,7 +10,17 @@ ; CHECK-SPIRV: ExtInstImport [[#EISId:]] "NonSemantic.Shader.DebugInfo.200" ; CHECK-SPIRV: String [[#LocalVarNameId:]] "A$1$upperbound" -; CHECK-SPIRV: TypeInt [[#TyInt64Id:]] 64 0 +; CHECK-SPIRV-DAG: TypeInt [[#TyInt32Id:]] 32 0 +; CHECK-SPIRV-DAG: TypeInt [[#TyInt64Id:]] 64 0 +; CHECK-NOT: THIS LINE IS USED TO SEPARATE DAGs +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant15Id:]] 15{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant24Id:]] 24{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant25Id:]] 25{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant27Id:]] 27{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant33Id:]] 33{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant34Id:]] 34{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant67Id:]] 67{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant68Id:]] 68{{[[:space:]]}} ; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1Id:]] 1 0 ; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1000Id:]] 1000 0 ; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone @@ -25,10 +35,22 @@ ; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#Constant1000Id]] [[#Constant1Id]] [[#DINoneId]] [[#DINoneId]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant15Id]] [[#Constant15Id]] [[#Constant67Id]] [[#Constant68Id]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant27Id]] [[#Constant27Id]] [[#Constant24Id]] [[#Constant25Id]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant34Id]] [[#Constant34Id]] [[#Constant33Id]] [[#Constant34Id]] + +; CHECK-LLVM: ![[#Scope_A:]] = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split" ; CHECK-LLVM: [[#Subrange1:]] = !DISubrange(lowerBound: 1, upperBound: ![[#UpperBound:]]) ; CHECK-LLVM: [[#UpperBound]] = !DILocalVariable(name: "A$1$upperbound" +; CHECK-LLVM: !DILocation(line: 15, column: 67, scope: ![[#Scope_A]] +; CHECK-LLVM: ![[#Scope_B:]] = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split" ; CHECK-LLVM: !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression()) +; CHECK-LLVM: !DILocation(line: 15, column: 67, scope: ![[#Scope_B]] +; CHECK-LLVM: ![[#Scope_C:]] = distinct !DISubprogram(name: "test_target_map_array_default_IP_test_array_map_no_map_type_.DIR.OMP.TARGET.340.split" ; CHECK-LLVM: !DISubrange(count: 1000, lowerBound: 1) +; CHECK-LLVM: !DILocation(line: 27, column: 24, scope: ![[#Scope_C]] +; CHECK-LLVM: ![[#Scope_D:]] = distinct !DISubprogram(name: "test" +; CHECK-LLVM: !DILocation(line: 34, column: 33, scope: ![[#Scope_D]] ; ModuleID = 'DebugInfoSubrangeUpperBound.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024" diff --git a/test/DebugInfo/NonSemantic/Shader200/DebugInfoTargetFunction.ll b/test/DebugInfo/NonSemantic/Shader200/DebugInfoTargetFunction.ll index 074305a..d2980cd 100644 --- a/test/DebugInfo/NonSemantic/Shader200/DebugInfoTargetFunction.ll +++ b/test/DebugInfo/NonSemantic/Shader200/DebugInfoTargetFunction.ll @@ -11,11 +11,30 @@ ; CHECK-SPIRV-DAG: String [[#Func:]] "foo_wrapper" ; CHECK-SPIRV-DAG: String [[#TargetFunc:]] "_Z3foov" +; CHECK-SPIRV-DAG: TypeInt [[#TyInt32Id:]] 32 0 +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant1Id:]] 1{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant2Id:]] 2{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant4Id:]] 4{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant5Id:]] 5{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant6Id:]] 6{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant8Id:]] 8{{[[:space:]]}} +; CHECK-SPIRV-DAG: Constant [[#TyInt32Id]] [[#Constant9Id:]] 9{{[[:space:]]}} + ; CHECK-SPIRV-DAG: ExtInst [[#]] [[#DebugNone:]] [[#]] DebugInfoNone ; CHECK-SPIRV-DAG: ExtInst [[#]] [[#]] [[#]] DebugFunction [[#Func]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#DebugNone]] [[#TargetFunc]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant4Id]] [[#Constant4Id]] [[#Constant5Id]] [[#Constant6Id]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant5Id]] [[#Constant5Id]] [[#Constant1Id]] [[#Constant2Id]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant8Id]] [[#Constant8Id]] [[#Constant5Id]] [[#Constant6Id]] +; CHECK-SPIRV: [[#EISId]] DebugLine [[#]] [[#Constant9Id]] [[#Constant9Id]] [[#Constant1Id]] [[#Constant2Id]] + ; CHECK-LLVM: define spir_func void @_Z11foo_wrapperv() {{.*}} !dbg ![[#DbgSubProg:]] { -; CHECK-LLVM: ![[#DbgSubProg]] = distinct !DISubprogram(name: "foo_wrapper", linkageName: "_Z11foo_wrapperv", scope: null, file: ![[#]], line: 3, type: ![[#]], scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], templateParams: ![[#]], retainedNodes: ![[#]], targetFuncName: "_Z3foov") +; CHECK-LLVM: ![[#Scope_foo_wrapper:]] = distinct !DISubprogram(name: "foo_wrapper", linkageName: "_Z11foo_wrapperv", scope: null, file: ![[#]], line: 3, type: ![[#]], scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], templateParams: ![[#]], retainedNodes: ![[#]], targetFuncName: "_Z3foov") +; CHECK-LLVM: !DILocation(line: 4, column: 5, scope: ![[#Scope_foo_wrapper]] +; CHECK-LLVM: !DILocation(line: 5, column: 1, scope: ![[#Scope_foo_wrapper]] +; CHECK-LLVM: ![[#Scope_boo:]] = distinct !DISubprogram(name: "boo", linkageName: "_Z3boov" +; CHECK-LLVM: !DILocation(line: 8, column: 5, scope: ![[#Scope_boo]] +; CHECK-LLVM: !DILocation(line: 9, column: 1, scope: ![[#Scope_boo]] ; ModuleID = 'example.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024" diff --git a/test/DebugInfo/NonSemantic/Shader200/DebugLinePriority.spt b/test/DebugInfo/NonSemantic/Shader200/DebugLinePriority.spt new file mode 100644 index 0000000..55ed4a9 --- /dev/null +++ b/test/DebugInfo/NonSemantic/Shader200/DebugLinePriority.spt @@ -0,0 +1,89 @@ +; RUN: llvm-spirv -to-binary %s -o %t.spv +; RUN: llvm-spirv -r %t.spv -o %t.rev.bc +; RUN: llvm-dis %t.rev.bc -o %t.rev.ll +; RUN: FileCheck < %t.rev.ll %s -check-prefix=CHECK-LLVM + +; CHECK-LLVM: %[[#Var:]] = load i32, i32* @_ZN5Outer5Inner6globalE, align 4, !dbg ![[#LineLoc:]] +; CHECK-LLVM: %inc = add nsw i32 %[[#Var]], 1, !dbg ![[#DebugLineLoc:]] +; CHECK-LLVM: ![[#LineLoc]] = !DILocation(line: 357, column: 113, scope: ![[#Scope:]]) +; CHECK-LLVM: ![[#DebugLineLoc]] = !DILocation(line: 8, column: 16, scope: ![[#Scope]]) + +119734787 66560 393230 54 0 +2 Capability Addresses +2 Capability Linkage +2 Capability Kernel +8 Extension "SPV_KHR_non_semantic_info" +5 ExtInstImport 1 "OpenCL.std" +11 ExtInstImport 2 "NonSemantic.Shader.DebugInfo.200" +3 MemoryModel 2 2 +10 String 14 "/path/to/inlined-namespace.cxx" +3 String 16 "0" +3 String 18 "" +4 String 23 "clang" +3 String 25 "int" +3 String 30 "foo" +4 String 31 "_Z3foov" +4 String 37 "Outer" +4 String 41 "Inner" +4 String 44 "global" +8 String 45 "_ZN5Outer5Inner6globalE" +3 Source 0 0 +8 Name 6 "_ZN5Outer5Inner6globalE" +4 Name 9 "_Z3foov" +4 Name 10 "entry" +3 Name 13 "inc" +10 Decorate 6 LinkageAttributes "_ZN5Outer5Inner6globalE" Export +4 Decorate 6 Alignment 4 +6 Decorate 9 LinkageAttributes "_Z3foov" Export +3 Decorate 13 NoSignedWrap +4 TypeInt 3 32 0 +4 Constant 3 5 0 +4 Constant 3 12 1 +4 Constant 3 20 65536 +4 Constant 3 21 4 +4 Constant 3 22 217 +4 Constant 3 26 32 +4 Constant 3 32 7 +4 Constant 3 33 136 +4 Constant 3 46 3 +4 Constant 3 47 8 +4 Constant 3 50 16 +4 Constant 3 52 9 +4 TypePointer 4 7 3 +2 TypeVoid 7 +3 TypeFunction 8 7 +2 TypeBool 38 +5 Variable 4 6 7 5 +3 ConstantTrue 38 39 +3 ConstantFalse 38 42 + +6 ExtInst 7 15 2 DebugSource 14 +7 ExtInst 7 17 2 DebugBuildIdentifier 16 12 +6 ExtInst 7 19 2 DebugStoragePath 18 +10 ExtInst 7 24 2 DebugCompilationUnit 20 21 15 22 23 +8 ExtInst 7 27 2 DebugTypeBasic 25 26 21 +5 ExtInst 7 28 2 DebugInfoNone +7 ExtInst 7 29 2 DebugTypeFunction 5 28 +15 ExtInst 7 34 2 DebugFunction 30 29 15 32 5 24 31 33 32 28 +6 ExtInst 7 36 2 DebugSource 18 +11 ExtInst 7 40 2 DebugLexicalBlock 36 5 5 24 37 39 +11 ExtInst 7 43 2 DebugLexicalBlock 36 5 5 40 41 42 +14 ExtInst 7 48 2 DebugGlobalVariable 44 27 15 46 5 43 45 6 47 + +5 Function 7 9 2 8 + +2 Label 10 +7 ExtInst 7 35 2 DebugFunctionDefinition 34 9 +6 ExtInst 7 49 2 DebugScope 34 +4 Line 14 357 113 +6 Load 3 11 6 2 4 +10 ExtInst 7 51 2 DebugLine 14 47 47 50 33 +5 IAdd 3 13 11 12 +5 ExtInst 7 511 2 DebugNoLine +5 ISub 3 137 11 12 +1 NoLine +5 Store 6 13 2 4 +1 Return + +1 FunctionEnd + -- 2.30.2