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
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
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();
}
InstCount = 37,
FunctionDefinition = 101,
SourceContinued = 102,
+ DebugLine = 103,
+ DebugNoLine = 104,
BuildIdentifier = 105,
StoragePath = 106,
EntryPoint = 107,
};
}
+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,
if (!Module)
return;
const std::shared_ptr<const SPIRVLine> &CurrLine = Module->getCurrentLine();
- if (Line && ((CurrLine && *Line != *CurrLine) || !CurrLine)) {
+ if (Line && (!CurrLine || *Line != *CurrLine)) {
O << *Line;
Module->setCurrentLine(Line);
}
Module->setCurrentLine(nullptr);
}
+namespace {
+bool isDebugLineEqual(const SPIRVExtInst &DL1, const SPIRVExtInst &DL2) {
+ std::vector<SPIRVWord> DL1Args = DL1.getArguments();
+ std::vector<SPIRVWord> 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<const SPIRVExtInst> &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);
SPIRVDBG(if (L) spvdbgs() << "[setLine] " << *L << '\n';)
}
+void SPIRVEntry::setDebugLine(const std::shared_ptr<const SPIRVExtInst> &DL) {
+ DebugLine = DL;
+ SPIRVDBG(if (DL) spvdbgs() << "[setDebugLine] " << *DL << '\n';)
+}
+
void SPIRVEntry::addMemberDecorate(SPIRVMemberDecorate *Dec) {
assert(canHaveMemberDecorates() &&
MemberDecorates.find(Dec->getPair()) == MemberDecorates.end());
void SPIRVLine::decode(std::istream &I) {
getDecoder(I) >> FileName >> Line >> Column;
- std::shared_ptr<const SPIRVLine> L(this);
- Module->setCurrentLine(L);
}
void SPIRVLine::validate() const {
return Id;
}
std::shared_ptr<const SPIRVLine> getLine() const { return Line; }
+ std::shared_ptr<const SPIRVExtInst> getDebugLine() const { return DebugLine; }
SPIRVLinkageTypeKind getLinkageType() const;
Op getOpCode() const { return OpCode; }
SPIRVModule *getModule() const { return Module; }
void setHasNoId() { Attrib |= SPIRVEA_NOID; }
void setId(SPIRVId TheId) { Id = TheId; }
void setLine(const std::shared_ptr<const SPIRVLine> &L);
+ void setDebugLine(const std::shared_ptr<const SPIRVExtInst> &DL);
void setLinkageType(SPIRVLinkageTypeKind);
void setModule(SPIRVModule *TheModule);
void setName(const std::string &TheName);
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;
DecorateIdMapType DecorateIds;
MemberDecorateMapType MemberDecorates;
std::shared_ptr<const SPIRVLine> Line;
+ std::shared_ptr<const SPIRVExtInst> DebugLine;
};
class SPIRVEntryNoIdGeneric : public SPIRVEntry {
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");
SPIRVEntry *Entry = Decoder.getEntry();
if (Decoder.OpCode == OpLine) {
- Module->add(Entry);
+ std::shared_ptr<const SPIRVLine> L(static_cast<SPIRVLine *>(Entry));
+ Module->setCurrentLine(L);
continue;
}
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<const SPIRVExtInst> DL(static_cast<SPIRVExtInst *>(Inst));
+ Module->setCurrentDebugLine(DL);
} else {
if (Inst->isExtInst(SPIRVEIS_Debug, SPIRVDebug::Scope) ||
Inst->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100, SPIRVDebug::Scope) ||
SPIRVWord Column) override;
const std::shared_ptr<const SPIRVLine> &getCurrentLine() const override;
void setCurrentLine(const std::shared_ptr<const SPIRVLine> &Line) override;
+ void addDebugLine(SPIRVEntry *E, SPIRVType *TheType, SPIRVId FileNameId,
+ SPIRVWord LineStart, SPIRVWord LineEnd,
+ SPIRVWord ColumnStart, SPIRVWord ColumnEnd) override;
+ const std::shared_ptr<const SPIRVExtInst> &
+ getCurrentDebugLine() const override;
+ void setCurrentDebugLine(
+ const std::shared_ptr<const SPIRVExtInst> &DebugLine) override;
void addCapability(SPIRVCapabilityKind) override;
void addCapabilityInternal(SPIRVCapabilityKind) override;
void addExtension(ExtensionID) override;
const std::vector<SPIRVValue *> &,
SPIRVBasicBlock *,
SPIRVInstruction * = nullptr) override;
+ SPIRVEntry *createDebugInfo(SPIRVWord, SPIRVType *TheType,
+ const std::vector<SPIRVWord> &) override;
SPIRVEntry *addDebugInfo(SPIRVWord, SPIRVType *TheType,
const std::vector<SPIRVWord> &) override;
SPIRVEntry *addModuleProcessed(const std::string &) override;
SPIRVStringVec StringVec;
SPIRVMemberNameVec MemberNameVec;
std::shared_ptr<const SPIRVLine> CurrentLine;
+ std::shared_ptr<const SPIRVExtInst> CurrentDebugLine;
SPIRVDecorateVec DecorateVec;
SPIRVDecGroupVec DecGroupVec;
SPIRVGroupDecVec GroupDecVec;
E->setLine(CurrentLine);
}
+const std::shared_ptr<const SPIRVExtInst> &
+SPIRVModuleImpl::getCurrentDebugLine() const {
+ return CurrentDebugLine;
+}
+
+void SPIRVModuleImpl::setCurrentDebugLine(
+ const std::shared_ptr<const SPIRVExtInst> &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<SPIRVWord> 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<SPIRVWord> 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<SPIRVExtInst *>(
+ createDebugInfo(SPIRVDebug::DebugLine, TheType, DebugLineOps)));
+ }
+
+ assert(E && "invalid entry");
+ E->setDebugLine(CurrentDebugLine);
+}
+
SPIRVValue *SPIRVModuleImpl::addSamplerConstant(SPIRVType *TheType,
SPIRVWord AddrMode,
SPIRVWord ParametricMode,
InsertBefore);
}
+SPIRVEntry *
+SPIRVModuleImpl::createDebugInfo(SPIRVWord InstId, SPIRVType *TheType,
+ const std::vector<SPIRVWord> &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<SPIRVWord> &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) {
SPIRVModuleImpl &MI = *static_cast<SPIRVModuleImpl *>(&M);
// Start tracking of the current line with no line
MI.CurrentLine.reset();
+ MI.CurrentDebugLine.reset();
SPIRVEncoder Encoder(O);
Encoder << MagicNumber << MI.SPIRVVersion
SPIRVWord Column) = 0;
virtual const std::shared_ptr<const SPIRVLine> &getCurrentLine() const = 0;
virtual void setCurrentLine(const std::shared_ptr<const SPIRVLine> &) = 0;
+ virtual void addDebugLine(SPIRVEntry *E, SPIRVType *TheType,
+ SPIRVId FileNameId, SPIRVWord LineStart,
+ SPIRVWord LineEnd, SPIRVWord ColumnStart,
+ SPIRVWord ColumnEnd) = 0;
+ virtual const std::shared_ptr<const SPIRVExtInst> &
+ getCurrentDebugLine() const = 0;
+ virtual void
+ setCurrentDebugLine(const std::shared_ptr<const SPIRVExtInst> &) = 0;
virtual const SPIRVDecorateGeneric *addDecorate(SPIRVDecorateGeneric *) = 0;
virtual SPIRVDecorationGroup *addDecorationGroup() = 0;
virtual SPIRVDecorationGroup *
const std::vector<SPIRVValue *> &,
SPIRVBasicBlock *,
SPIRVInstruction * = nullptr) = 0;
+ virtual SPIRVEntry *createDebugInfo(SPIRVWord, SPIRVType *,
+ const std::vector<SPIRVWord> &) = 0;
virtual SPIRVEntry *addDebugInfo(SPIRVWord, SPIRVType *,
const std::vector<SPIRVWord> &) = 0;
virtual SPIRVEntry *addModuleProcessed(const std::string &) = 0;
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<SPIRVExtension *>(Entry);
; 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
; 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"
; 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
; 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"
; 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"
--- /dev/null
+; 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
+