EXT(SPV_KHR_bit_instructions)
EXT(SPV_KHR_uniform_group_instructions)
EXT(SPV_KHR_subgroup_rotate)
+EXT(SPV_KHR_non_semantic_info)
EXT(SPV_INTEL_subgroups)
EXT(SPV_INTEL_media_block_io)
EXT(SPV_INTEL_device_side_avc_motion_estimation)
SPIRV_Debug,
OpenCL_DebugInfo_100,
NonSemantic_Shader_DebugInfo_100,
- NonSemantic_Kernel_DebugInfo_100
+ NonSemantic_Shader_DebugInfo_200
};
/// \brief Helper class to manage SPIR-V translation
return I->second;
}
+ void setAllowedToUseExtension(ExtensionID Extension, bool Allow = true) {
+ ExtStatusMap[Extension] = Allow;
+ }
+
VersionNumber getMaxVersion() const { return MaxVersion; }
bool isGenArgNameMDEnabled() const { return GenKernelArgNameMD; }
if (!MDN)
return BM->addDebugInfo(SPIRVDebug::DebugInfoNone, getVoidTy(),
SPIRVWordVec());
+ if (isNonSemanticDebugInfo())
+ BM->addExtension(SPIRV::ExtensionID::SPV_KHR_non_semantic_info);
if (const DINode *DIEntry = dyn_cast<DINode>(MDN)) {
switch (DIEntry->getTag()) {
// Types
return transDbgArrayType(cast<DICompositeType>(DIEntry));
case dwarf::DW_TAG_subrange_type:
- if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
+ if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
return transDbgSubrangeType(cast<DISubrange>(DIEntry));
else
return getDebugInfoNone();
case dwarf::DW_TAG_string_type: {
- if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
+ if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
return transDbgStringType(cast<DIStringType>(DIEntry));
return getDebugInfoNone();
}
case dwarf::DW_TAG_module: {
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_debug_module) ||
- BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
+ BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
return transDbgModule(cast<DIModule>(DIEntry));
return getDebugInfoNone();
}
return VoidT;
}
+SPIRVType *LLVMToSPIRVDbgTran::getInt32Ty() {
+ if (!Int32T) {
+ assert(M && "Pointer to LLVM Module is expected to be initialized!");
+ // Cache int32 type in a member.
+ Int32T = SPIRVWriter->transType(Type::getInt32Ty(M->getContext()));
+ }
+ return Int32T;
+}
+
SPIRVEntry *LLVMToSPIRVDbgTran::getScope(DIScope *S) {
if (S)
return transDbgEntry(S);
return getDebugInfoNone();
}
+inline bool LLVMToSPIRVDbgTran::isNonSemanticDebugInfo() {
+ return (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
+ BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200);
+}
+
+void LLVMToSPIRVDbgTran::transformToConstant(std::vector<SPIRVWord> &Ops,
+ std::vector<SPIRVWord> Idxs) {
+ for (const auto Idx : Idxs) {
+ SPIRVValue *Const = BM->addIntegerConstant(
+ static_cast<SPIRVTypeInt *>(getInt32Ty()), Ops[Idx]);
+ Ops[Idx] = Const->getId();
+ }
+}
+
SPIRVWord mapDebugFlags(DINode::DIFlags DFlags) {
SPIRVWord Flags = 0;
if ((DFlags & DINode::FlagAccessibility) == DINode::FlagPublic)
// Fortran dynamic arrays can have following 'dataLocation', 'associated'
// 'allocated' and 'rank' debug metadata. Such arrays are being mapped on
-// DebugTypeArrayDynamic from NonSemantic.Kernel.100 debug spec
+// DebugTypeArrayDynamic from NonSemantic.Shader.200 debug spec
inline bool isFortranArrayDynamic(const DICompositeType *AT) {
return (AT->getRawDataLocation() || AT->getRawAssociated() ||
AT->getRawAllocated() || AT->getRawRank());
auto DwarfLang =
static_cast<llvm::dwarf::SourceLanguage>(CU->getSourceLanguage());
Ops[LanguageIdx] =
- BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100
+ BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200
? convertDWARFSourceLangToSPIRVNonSemanticDbgInfo(DwarfLang)
: convertDWARFSourceLangToSPIRV(DwarfLang);
+ if (isNonSemanticDebugInfo())
+ transformToConstant(
+ Ops, {SPIRVDebugInfoVersionIdx, DWARFVersionIdx, LanguageIdx});
BM->addModuleProcessed(SPIRVDebug::ProducerPrefix + CU->getProducer().str());
// Cache CU in a member.
SPIRVCU = static_cast<SPIRVExtInst *>(
SPIRVDebug::EncodingTag EncTag = SPIRVDebug::Unspecified;
SPIRV::DbgEncodingMap::find(Encoding, &EncTag);
Ops[EncodingIdx] = EncTag;
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {EncodingIdx});
return BM->addDebugInfo(SPIRVDebug::TypeBasic, getVoidTy(), Ops);
}
Ops[StorageClassIdx] = SPIRSPIRVAddrSpaceMap::map(SPIRAS);
}
Ops[FlagsIdx] = transDebugFlags(PT);
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {StorageClassIdx, FlagsIdx});
SPIRVEntry *Res = BM->addDebugInfo(SPIRVDebug::TypePointer, getVoidTy(), Ops);
return Res;
}
Ops[BaseTypeIdx] = Base->getId();
Ops[QualifierIdx] = SPIRV::DbgTypeQulifierMap::map(
static_cast<llvm::dwarf::Tag>(QT->getTag()));
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {QualifierIdx});
return BM->addDebugInfo(SPIRVDebug::TypeQualifier, getVoidTy(), Ops);
}
SPIRVEntry *LLVMToSPIRVDbgTran::transDbgArrayType(const DICompositeType *AT) {
- if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) {
+ if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
if (isFortranArrayDynamic(AT))
return transDbgArrayTypeDynamic(AT);
return transDbgArrayTypeNonSemantic(AT);
if (AT->isVector()) {
assert(N == 1 && "Multidimensional vector is not expected!");
Ops[ComponentCountIdx] = static_cast<SPIRVWord>(Count->getZExtValue());
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {ComponentCountIdx});
return BM->addDebugInfo(SPIRVDebug::TypeVector, getVoidTy(), Ops);
}
if (Count) {
SPIRVEntry *Scope = getScope(DT->getScope());
assert(Scope && "Couldn't translate scope!");
Ops[ParentIdx] = Scope->getId();
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::Typedef, getVoidTy(), Ops);
}
Ops[ReturnTypeIdx] = getVoidTy()->getId();
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::TypeFunction, getVoidTy(), Ops);
}
SPIRVString *Name = BM->getString(E->getName().str());
Ops.push_back(Name->getId());
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::TypeEnum, getVoidTy(), Ops);
}
Ops.push_back(transDbgEntry(N)->getId());
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
SPIRVEntry *Res =
BM->addDebugInfo(SPIRVDebug::TypeComposite, getVoidTy(), Ops);
Ops.push_back(Val->getId());
}
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::TypeMember, getVoidTy(), Ops);
}
ConstantInt *Size = getUInt(M, DT->getSizeInBits());
Ops[SizeIdx] = SPIRVWriter->transValue(Size, nullptr)->getId();
Ops[FlagsIdx] = transDebugFlags(DT);
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::Inheritance, getVoidTy(), Ops);
}
Ops[SourceIdx] = getDebugInfoNoneId();
Ops[LineIdx] = 0; // This version of DITemplateParameter has no line number
Ops[ColumnIdx] = 0; // This version of DITemplateParameter has no column info
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::TypeTemplateParameter, getVoidTy(), Ops);
}
Ops[SourceIdx] = getDebugInfoNoneId();
Ops[LineIdx] = 0; // This version of DITemplateValueParameter has no line info
Ops[ColumnIdx] = 0; // This version of DITemplateValueParameter has no column
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::TypeTemplateTemplateParameter,
getVoidTy(), Ops);
}
SPIRVEntry *P = transDbgEntry(cast<DINode>(Op.get()));
Ops.push_back(P->getId());
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::TypeTemplateParameterPack, getVoidTy(),
Ops);
}
if (DIDerivedType *StaticMember = GV->getStaticDataMemberDeclaration())
Ops.push_back(transDbgEntry(StaticMember)->getId());
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::GlobalVariable, getVoidTy(), Ops);
}
Ops[ParentIdx] = getScope(Scope)->getId();
Ops[LinkageNameIdx] = BM->getString(Func->getLinkageName().str())->getId();
Ops[FlagsIdx] = adjustAccessFlags(Scope, transDebugFlags(Func));
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
SPIRVEntry *DebugFunc = nullptr;
if (!Func->isDefinition()) {
using namespace SPIRVDebug::Operand::Function;
Ops.resize(MinOperandCount);
Ops[ScopeLineIdx] = Func->getScopeLine();
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {ScopeLineIdx});
Ops[FunctionIdIdx] = getDebugInfoNoneId();
for (const llvm::Function &F : M->functions()) {
Ops.push_back(transDbgEntry(FuncDecl)->getId());
else {
Ops.push_back(getDebugInfoNoneId());
- if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) {
+ if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
// Translate targetFuncName mostly for Fortran trampoline function if it
// is the case
StringRef TargetFunc = Func->getTargetFuncName();
Ops[SourceIdx] = getSource(S)->getId();
Ops[DiscriminatorIdx] = LBF->getDiscriminator();
Ops[ParentIdx] = getScope(S->getScope())->getId();
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {DiscriminatorIdx});
return BM->addDebugInfo(SPIRVDebug::LexicalBlockDiscriminator, getVoidTy(),
Ops);
}
Ops[ColumnIdx] = 0; // This version of DINamespace has no column number
Ops.push_back(BM->getString(NS->getName().str())->getId());
}
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::LexicalBlock, getVoidTy(), Ops);
}
Ops[ScopeIdx] = getScope(Loc->getScope())->getId();
if (DILocation *IA = Loc->getInlinedAt())
Ops.push_back(transDbgEntry(IA)->getId());
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx});
return BM->addDebugInfo(SPIRVDebug::InlinedAt, getVoidTy(), Ops);
}
Ops[FlagsIdx] = transDebugFlags(Var);
if (SPIRVWord ArgNumber = Var->getArg())
Ops.push_back(ArgNumber);
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
return BM->addDebugInfo(SPIRVDebug::LocalVariable, getVoidTy(), Ops);
}
unsigned OpCount = OpCountMap[OC];
SPIRVWordVec Op(OpCount);
Op[OpCodeIdx] = OC;
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Op, {OpCodeIdx});
for (unsigned J = 1; J < OpCount; ++J)
Op[J] = Expr->getElement(++I);
auto *Operation = BM->addDebugInfo(SPIRVDebug::Operation, getVoidTy(), Op);
Ops[LineIdx] = IE->getLine();
Ops[ColumnIdx] = 0; // This version of DIImportedEntity has no column number
Ops[ParentIdx] = getScope(IE->getScope())->getId();
+ if (isNonSemanticDebugInfo())
+ transformToConstant(Ops, {TagIdx, LineIdx, ColumnIdx});
return BM->addDebugInfo(SPIRVDebug::ImportedEntity, getVoidTy(), Ops);
}
SPIRVEntry *LLVMToSPIRVDbgTran::transDbgModule(const DIModule *Module) {
using namespace SPIRVDebug::Operand::ModuleINTEL;
SPIRVWordVec Ops(OperandCount);
- // The difference in translation of NonSemantic Debug Info and
- // SPV_INTEL_debug_module extension is that extension allows Line and IsDecl
- // operands to be Literals, when the non-OpenCL Debug Info allows only IDs to
- // the constant values.
- bool IsNonSemanticDI =
- (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100);
Ops[NameIdx] = BM->getString(Module->getName().str())->getId();
Ops[SourceIdx] = getSource(Module->getFile())->getId();
- if (IsNonSemanticDI) {
- ConstantInt *Line = getUInt(M, Module->getLineNo());
- Ops[LineIdx] = SPIRVWriter->transValue(Line, nullptr)->getId();
- } else {
- Ops[LineIdx] = Module->getLineNo();
- }
+ Ops[LineIdx] = Module->getLineNo();
Ops[ParentIdx] = getScope(Module->getScope())->getId();
Ops[ConfigMacrosIdx] =
BM->getString(Module->getConfigurationMacros().str())->getId();
Ops[IncludePathIdx] = BM->getString(Module->getIncludePath().str())->getId();
Ops[ApiNotesIdx] = BM->getString(Module->getAPINotesFile().str())->getId();
- if (IsNonSemanticDI) {
- ConstantInt *IsDecl = getUInt(M, Module->getIsDecl());
- Ops[IsDeclIdx] = SPIRVWriter->transValue(IsDecl, nullptr)->getId();
- } else {
- Ops[IsDeclIdx] = Module->getIsDecl();
- }
- if (IsNonSemanticDI)
+ Ops[IsDeclIdx] = Module->getIsDecl();
+ if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
+ // The difference in translation of NonSemantic Debug Info and
+ // SPV_INTEL_debug_module extension is that extension allows Line and IsDecl
+ // operands to be Literals, when the non-OpenCL Debug Info allows only IDs
+ // to the constant values.
+ transformToConstant(Ops, {LineIdx, IsDeclIdx});
return BM->addDebugInfo(SPIRVDebug::Module, getVoidTy(), Ops);
+ }
BM->addExtension(ExtensionID::SPV_INTEL_debug_module);
BM->addCapability(spv::CapabilityDebugInfoModuleINTEL);
return BM->addDebugInfo(SPIRVDebug::ModuleINTEL, getVoidTy(), Ops);
// Helper methods
SPIRVType *getVoidTy();
+ SPIRVType *getInt32Ty();
SPIRVEntry *getScope(DIScope *SR);
SPIRVEntry *getGlobalVariable(const DIGlobalVariable *GV);
+ inline bool isNonSemanticDebugInfo();
+ void transformToConstant(std::vector<SPIRVWord> &Ops,
+ std::vector<SPIRVWord> Idxs);
// No debug info
SPIRVEntry *getDebugInfoNone();
std::unordered_map<const MDNode *, SPIRVEntry *> MDMap;
std::unordered_map<std::string, SPIRVExtInst *> FileMap;
DebugInfoFinder DIF;
- SPIRVType *VoidT;
+ SPIRVType *VoidT = nullptr;
+ SPIRVType *Int32T = nullptr;
SPIRVEntry *DebugInfoNone;
SPIRVExtInst *SPIRVCU;
std::vector<const DbgVariableIntrinsic *> DbgDeclareIntrinsics;
return mapValue(BV, transOCLBuiltinFromExtInst(ExtInst, BB));
case SPIRVEIS_Debug:
case SPIRVEIS_OpenCL_DebugInfo_100:
- case SPIRVEIS_NonSemantic_Kernel_DebugInfo_100:
+ case SPIRVEIS_NonSemantic_Shader_DebugInfo_200:
return mapValue(BV, DbgTran->transDebugIntrinsic(ExtInst, BB));
default:
llvm_unreachable("Unknown extended instruction set!");
EI->getExtSetKind() == SPIRV::SPIRVEIS_OpenCL_DebugInfo_100 ||
EI->getExtSetKind() ==
SPIRV::SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
- EI->getExtSetKind() == SPIRV::SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
+ EI->getExtSetKind() == SPIRV::SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
return EI;
}
return nullptr;
}
+// Check if module is generated using NonSemantic.Shader.DebugInfo.XXX
+// extended instruction set
+inline bool isNonSemanticDebugInfo(const SPIRVExtInstSetKind Kind) {
+ return (Kind == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
+ Kind == SPIRVEIS_NonSemantic_Shader_DebugInfo_200);
+}
+
+// Get integer parameter of debug instruction considering whether it's
+// Literal or <id> of OpConstant instruction depending on DebugInfo
+// extended instruction set kind
+SPIRVWord
+SPIRVToLLVMDbgTran::getConstantValueOrLiteral(const std::vector<SPIRVWord> &Ops,
+ const SPIRVWord Idx,
+ const SPIRVExtInstSetKind Kind) {
+ if (!isNonSemanticDebugInfo(Kind))
+ return Ops[Idx];
+
+ SPIRVValue *SPVConst = BM->get<SPIRVValue>(Ops[Idx]);
+ assert(isConstantOpCode(SPVConst->getOpCode()) &&
+ "NonSemantic Debug instruction's parameters must be OpConstant");
+ ConstantInt *Const =
+ cast<ConstantInt>(SPIRVReader->transValue(SPVConst, nullptr, nullptr));
+ return Const->getZExtValue();
+}
+
const std::string &SPIRVToLLVMDbgTran::getString(const SPIRVId Id) {
SPIRVString *String = BM->get<SPIRVString>(Id);
assert(String && "Invalid string");
using namespace SPIRVDebug::Operand::CompilationUnit;
assert(Ops.size() == OperandCount && "Invalid number of operands");
- M->addModuleFlag(llvm::Module::Max, "Dwarf Version", Ops[DWARFVersionIdx]);
- unsigned SourceLang =
- DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100
- ? convertSPIRVSourceLangToDWARFNonSemanticDbgInfo(Ops[LanguageIdx])
- : convertSPIRVSourceLangToDWARF(Ops[LanguageIdx]);
+ SPIRVWord DWARFVersion = getConstantValueOrLiteral(
+ Ops, DWARFVersionIdx, DebugInst->getExtSetKind());
+ M->addModuleFlag(llvm::Module::Max, "Dwarf Version", DWARFVersion);
+ SPIRVWord SourceLang =
+ getConstantValueOrLiteral(Ops, LanguageIdx, DebugInst->getExtSetKind());
+ if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
+ SourceLang = convertSPIRVSourceLangToDWARFNonSemanticDbgInfo(SourceLang);
+ else
+ SourceLang = convertSPIRVSourceLangToDWARF(SourceLang);
auto Producer = findModuleProducer();
CU = Builder.createCompileUnit(SourceLang, getFile(Ops[SourceIdx]), Producer,
false, "", 0);
const SPIRVWordVec &Ops = DebugInst->getArguments();
assert(Ops.size() == OperandCount && "Invalid number of operands");
StringRef Name = getString(Ops[NameIdx]);
- auto Tag = static_cast<SPIRVDebug::EncodingTag>(Ops[EncodingIdx]);
+ auto Tag = static_cast<SPIRVDebug::EncodingTag>(
+ getConstantValueOrLiteral(Ops, EncodingIdx, DebugInst->getExtSetKind()));
unsigned Encoding = SPIRV::DbgEncodingMap::rmap(Tag);
if (Encoding == 0)
return Builder.createUnspecifiedType(Name);
assert(Ops.size() == OperandCount && "Invalid number of operands");
DIType *BaseTy =
transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[BaseTypeIdx]));
- unsigned Tag = SPIRV::DbgTypeQulifierMap::rmap(
- static_cast<SPIRVDebug::TypeQualifierTag>(Ops[QualifierIdx]));
+ SPIRVWord Tag = SPIRV::DbgTypeQulifierMap::rmap(
+ static_cast<SPIRVDebug::TypeQualifierTag>(getConstantValueOrLiteral(
+ Ops, QualifierIdx, DebugInst->getExtSetKind())));
return Builder.createQualifiedType(Tag, BaseTy);
}
DIType *PointeeTy = nullptr;
if (BM->getEntry(Ops[BaseTypeIdx])->getOpCode() != OpTypeVoid)
PointeeTy = transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[BaseTypeIdx]));
- Optional<unsigned> AS;
- if (Ops[StorageClassIdx] != ~0U) {
- auto SC = static_cast<SPIRVStorageClassKind>(Ops[StorageClassIdx]);
- AS = SPIRSPIRVAddrSpaceMap::rmap(SC);
- }
+ llvm::Optional<unsigned> AS;
+ SPIRVWord SC = getConstantValueOrLiteral(Ops, StorageClassIdx,
+ DebugInst->getExtSetKind());
+ if (SC != ~0U) // all ones denote no address space
+ AS = SPIRSPIRVAddrSpaceMap::rmap(static_cast<SPIRVStorageClassKind>(SC));
DIType *Ty;
- SPIRVWord Flags = Ops[FlagsIdx];
+ SPIRVWord Flags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
if (Flags & SPIRVDebug::FlagIsLValueReference)
Ty = Builder.createReferenceType(dwarf::DW_TAG_reference_type, PointeeTy, 0,
0, AS);
DICompositeType *
SPIRVToLLVMDbgTran::transTypeArray(const SPIRVExtInst *DebugInst) {
- if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
+ if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200)
return transTypeArrayNonSemantic(DebugInst);
+ // TODO: figure out better naming for transTypeArrayOpenCL since
+ // it also handles SPIRVEIS_NonSemantic_Shader_DebugInfo_100.
+ // Also to consider separating OpenCL from NonSemantic, as OpenCL has several
+ // workarounds
return transTypeArrayOpenCL(DebugInst);
}
assert(Ops.size() >= MinOperandCount && "Invalid number of operands");
DIType *BaseTy =
transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[BaseTypeIdx]));
- SPIRVWord Count = Ops[ComponentCountIdx];
+ SPIRVWord Count = getConstantValueOrLiteral(Ops, ComponentCountIdx,
+ DebugInst->getExtSetKind());
// FIXME: The current design of SPIR-V Debug Info doesn't provide a field
// for the derived memory size. Meanwhile, OpenCL/SYCL 3-element vectors
// occupy the same amount of memory as 4-element vectors, hence the simple
StringRef Name = getString(Ops[NameIdx]);
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIScope *ParentScope = getScope(BM->getEntry(Ops[ParentIdx]));
uint64_t Size = 0;
if (!(SizeEntry->isExtInst(SPIRVEIS_Debug, SPIRVDebug::DebugInfoNone) ||
SizeEntry->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100,
SPIRVDebug::DebugInfoNone) ||
- SizeEntry->isExtInst(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
+ SizeEntry->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200,
SPIRVDebug::DebugInfoNone))) {
Size = BM->get<SPIRVConstant>(Ops[SizeIdx])->getZExtIntValue();
}
Identifier = static_cast<SPIRVString *>(UniqId)->getStr();
DINode::DIFlags Flags = DINode::FlagZero;
- if (Ops[FlagsIdx] & SPIRVDebug::FlagIsFwdDecl)
+ SPIRVWord SPIRVFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
+ if (SPIRVFlags & SPIRVDebug::FlagIsFwdDecl)
Flags |= DINode::FlagFwdDecl;
- if (Ops[FlagsIdx] & SPIRVDebug::FlagTypePassByValue)
+ if (SPIRVFlags & SPIRVDebug::FlagTypePassByValue)
Flags |= DINode::FlagTypePassByValue;
- if (Ops[FlagsIdx] & SPIRVDebug::FlagTypePassByReference)
+ if (SPIRVFlags & SPIRVDebug::FlagTypePassByReference)
Flags |= DINode::FlagTypePassByReference;
DICompositeType *CT = nullptr;
- switch (Ops[TagIdx]) {
+ switch (getConstantValueOrLiteral(Ops, TagIdx, DebugInst->getExtSetKind())) {
case SPIRVDebug::Class:
// TODO: should be replaced with createClassType, when bug with creating
// ClassType with llvm::dwarf::DW_TAG_struct_type tag will be fixed
assert(Ops.size() >= MinOperandCount && "Invalid number of operands");
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
StringRef Name = getString(Ops[NameIdx]);
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
DIType *BaseType =
transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[TypeIdx]));
uint64_t OffsetInBits =
BM->get<SPIRVConstant>(Ops[OffsetIdx])->getZExtIntValue();
- unsigned SPIRVFlags = Ops[FlagsIdx];
+ SPIRVWord SPIRVFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
DINode::DIFlags Flags = DINode::FlagZero;
if ((SPIRVDebug::FlagAccess & SPIRVFlags) == SPIRVDebug::FlagIsPublic) {
Flags |= DINode::FlagPublic;
StringRef Name = getString(Ops[NameIdx]);
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
uint64_t SizeInBits = BM->get<SPIRVConstant>(Ops[SizeIdx])->getZExtIntValue();
- unsigned AlignInBits = 0;
- SPIRVWord Flags = Ops[FlagsIdx];
+ SPIRVWord AlignInBits = 0;
+ SPIRVWord Flags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
if (Flags & SPIRVDebug::FlagIsFwdDecl) {
return Builder.createForwardDecl(dwarf::DW_TAG_enumeration_type, Name,
Scope, File, LineNo, AlignInBits,
const SPIRVWordVec &Ops = DebugInst->getArguments();
assert(Ops.size() >= MinOperandCount && "Invalid number of operands");
- SPIRVWord SPIRVFlags = Ops[FlagsIdx];
+ SPIRVWord SPIRVFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
DINode::DIFlags Flags = DINode::FlagZero;
if (SPIRVFlags & SPIRVDebug::FlagIsLValueReference)
Flags |= llvm::DINode::FlagLValueReference;
const SPIRVWordVec &Ops = DebugInst->getArguments();
DIScope *ParentScope = getScope(BM->getEntry(Ops[ParentIdx]));
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
if (Ops.size() > NameIdx) {
StringRef Name = getString(Ops[NameIdx]);
return Builder.createNameSpace(ParentScope, Name,
using namespace SPIRVDebug::Operand::LexicalBlockDiscriminator;
const SPIRVWordVec &Ops = DebugInst->getArguments();
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned Disc = Ops[DiscriminatorIdx];
+ SPIRVWord Disc = getConstantValueOrLiteral(Ops, DiscriminatorIdx,
+ DebugInst->getExtSetKind());
DIScope *ParentScope = getScope(BM->getEntry(Ops[ParentIdx]));
return Builder.createLexicalBlockFile(ParentScope, File, Disc);
}
DISubroutineType *Ty =
transDebugInst<DISubroutineType>(BM->get<SPIRVExtInst>(Ops[TypeIdx]));
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
StringRef LinkageName = getString(Ops[LinkageNameIdx]);
- SPIRVWord SPIRVDebugFlags = Ops[FlagsIdx];
+ SPIRVWord SPIRVDebugFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
DINode::DIFlags Flags = DINode::FlagZero;
if (SPIRVDebugFlags & SPIRVDebug::FlagIsArtificial)
Flags |= llvm::DINode::FlagArtificial;
DISubprogram::toSPFlags(IsLocal, IsDefinition, IsOptimized,
DISubprogram::SPFlagNonvirtual, IsMainSubprogram);
- unsigned ScopeLine = Ops[ScopeLineIdx];
+ SPIRVWord ScopeLine =
+ getConstantValueOrLiteral(Ops, ScopeLineIdx, DebugInst->getExtSetKind());
// Function declaration descriptor
DISubprogram *FD = nullptr;
StringRef Name = getString(Ops[NameIdx]);
StringRef LinkageName = getString(Ops[LinkageNameIdx]);
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DISubroutineType *Ty =
transDebugInst<DISubroutineType>(BM->get<SPIRVExtInst>(Ops[TypeIdx]));
- SPIRVWord SPIRVDebugFlags = Ops[FlagsIdx];
+ SPIRVWord SPIRVDebugFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
bool IsDefinition = SPIRVDebugFlags & SPIRVDebug::FlagIsDefinition;
bool IsOptimized = SPIRVDebugFlags & SPIRVDebug::FlagIsOptimized;
bool IsLocal = SPIRVDebugFlags & SPIRVDebug::FlagIsLocal;
StringRef Name = getString(Ops[NameIdx]);
DIType *Ty = transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[TypeIdx]));
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIScope *Parent = getScope(BM->getEntry(Ops[ParentIdx]));
StringRef LinkageName = getString(Ops[LinkageNameIdx]);
StaticMemberDecl = transDebugInst<DIDerivedType>(
BM->get<SPIRVExtInst>(Ops[StaticMemberDeclarationIdx]));
}
- bool IsLocal = Ops[FlagsIdx] & SPIRVDebug::FlagIsLocal;
- bool IsDefinition = Ops[FlagsIdx] & SPIRVDebug::FlagIsDefinition;
+ SPIRVWord Flags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
+ bool IsLocal = Flags & SPIRVDebug::FlagIsLocal;
+ bool IsDefinition = Flags & SPIRVDebug::FlagIsDefinition;
MDNode *VarDecl = nullptr;
if (IsDefinition) {
VarDecl = Builder.createGlobalVariableExpression(
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
StringRef Name = getString(Ops[NameIdx]);
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIType *Ty = transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[TypeIdx]));
DINode::DIFlags Flags = DINode::FlagZero;
- if (Ops[FlagsIdx] & SPIRVDebug::FlagIsArtificial)
+ SPIRVWord SPIRVFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
+ if (SPIRVFlags & SPIRVDebug::FlagIsArtificial)
Flags |= DINode::FlagArtificial;
- if (Ops[FlagsIdx] & SPIRVDebug::FlagIsObjectPointer)
+ if (SPIRVFlags & SPIRVDebug::FlagIsObjectPointer)
Flags |= DINode::FlagObjectPointer;
if (Ops.size() > ArgNumberIdx)
assert(Ops.size() >= OperandCount && "Invalid number of operands");
DIFile *File = getFile(Ops[SourceIdx]);
- unsigned LineNo = Ops[LineIdx];
+ SPIRVWord LineNo =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
StringRef Alias = getString(Ops[NameIdx]);
SPIRVEntry *TypeInst = BM->getEntry(Ops[BaseTypeIdx]);
DIType *Ty = transDebugInst<DIType>(static_cast<SPIRVExtInst *>(TypeInst));
transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[ParentIdx]));
DIType *Child = transDebugInst<DIType>(BM->get<SPIRVExtInst>(Ops[ChildIdx]));
DINode::DIFlags Flags = DINode::FlagZero;
- if ((Ops[FlagsIdx] & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPublic)
+ SPIRVWord SPIRVFlags =
+ getConstantValueOrLiteral(Ops, FlagsIdx, DebugInst->getExtSetKind());
+ if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPublic)
Flags |= llvm::DINode::FlagPublic;
- if ((Ops[FlagsIdx] & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsProtected)
+ if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsProtected)
Flags |= llvm::DINode::FlagProtected;
- if ((Ops[FlagsIdx] & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPrivate)
+ if ((SPIRVFlags & SPIRVDebug::FlagAccess) == SPIRVDebug::FlagIsPrivate)
Flags |= llvm::DINode::FlagPrivate;
uint64_t Offset = BM->get<SPIRVConstant>(Ops[OffsetIdx])->getZExtIntValue();
return Builder.createInheritance(Child, Parent, Offset, 0, Flags);
const SPIRVWordVec &Ops = DebugInst->getArguments();
assert(Ops.size() >= OperandCount && "Invalid number of operands");
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
- unsigned Line = Ops[LineIdx];
+ SPIRVWord Line =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIFile *File = getFile(Ops[SourceIdx]);
auto *Entity = transDebugInst<DINode>(BM->get<SPIRVExtInst>(Ops[EntityIdx]));
- if (Ops[TagIdx] == SPIRVDebug::ImportedModule) {
+ SPIRVWord Tag =
+ getConstantValueOrLiteral(Ops, TagIdx, DebugInst->getExtSetKind());
+ if (Tag == SPIRVDebug::ImportedModule) {
if (!Entity)
return Builder.createImportedModule(
Scope, static_cast<DIImportedEntity *>(nullptr), File, Line);
if (DINamespace *NS = dyn_cast<DINamespace>(Entity))
return Builder.createImportedModule(Scope, NS, File, Line);
}
- if (Ops[TagIdx] == SPIRVDebug::ImportedDeclaration) {
+ if (Tag == SPIRVDebug::ImportedDeclaration) {
StringRef Name = getString(Ops[NameIdx]);
if (DIGlobalVariableExpression *GVE =
dyn_cast<DIGlobalVariableExpression>(Entity))
using namespace SPIRVDebug::Operand::ModuleINTEL;
const SPIRVWordVec &Ops = DebugInst->getArguments();
assert(Ops.size() >= OperandCount && "Invalid number of operands");
- bool IsNonSemanticDI =
- (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100);
DIScope *Scope = getScope(BM->getEntry(Ops[ParentIdx]));
- auto GetInt = [&](SPIRVId Id) -> ConstantInt * {
- auto *V = BM->get<SPIRVValue>(Id);
- return cast<ConstantInt>(SPIRVReader->transValue(V, nullptr, nullptr));
- };
- unsigned Line =
- IsNonSemanticDI ? GetInt(Ops[LineIdx])->getZExtValue() : Ops[LineIdx];
+ SPIRVWord Line =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
DIFile *File = getFile(Ops[SourceIdx]);
StringRef Name = getString(Ops[NameIdx]);
StringRef ConfigMacros = getString(Ops[ConfigMacrosIdx]);
StringRef IncludePath = getString(Ops[IncludePathIdx]);
StringRef ApiNotes = getString(Ops[ApiNotesIdx]);
bool IsDecl =
- IsNonSemanticDI ? GetInt(Ops[IsDeclIdx])->getZExtValue() : Ops[IsDeclIdx];
-
+ getConstantValueOrLiteral(Ops, IsDeclIdx, DebugInst->getExtSetKind());
return Builder.createModule(Scope, Name, ConfigMacros, IncludePath, ApiNotes,
File, Line, IsDecl);
}
const SPIRVWordVec &Args = DebugInst->getArguments();
std::vector<uint64_t> Ops;
for (SPIRVId A : Args) {
+ using namespace SPIRVDebug::Operand::Operation;
SPIRVExtInst *O = BM->get<SPIRVExtInst>(A);
const SPIRVWordVec &Operands = O->getArguments();
- auto OpCode = static_cast<SPIRVDebug::ExpressionOpCode>(Operands[0]);
+ auto OpCode =
+ static_cast<SPIRVDebug::ExpressionOpCode>(getConstantValueOrLiteral(
+ Operands, OpCodeIdx, DebugInst->getExtSetKind()));
Ops.push_back(SPIRV::DbgExpressionOpCodeMap::rmap(OpCode));
for (unsigned I = 1, E = Operands.size(); I < E; ++I) {
Ops.push_back(Operands[I]);
return DebugLoc();
}
-MDNode *SPIRVToLLVMDbgTran::transDebugInlined(const SPIRVExtInst *Inst) {
+MDNode *SPIRVToLLVMDbgTran::transDebugInlined(const SPIRVExtInst *DebugInst) {
using namespace SPIRVDebug::Operand::InlinedAt;
- SPIRVWordVec Ops = Inst->getArguments();
+ SPIRVWordVec Ops = DebugInst->getArguments();
assert(Ops.size() >= MinOperandCount && "Invalid number of operands");
- unsigned Line = Ops[LineIdx];
+ SPIRVWord Line =
+ getConstantValueOrLiteral(Ops, LineIdx, DebugInst->getExtSetKind());
unsigned Col = 0; // DebugInlinedAt instruction has no column operand
DILocalScope *Scope =
cast<DILocalScope>(getScope(BM->getEntry(Ops[ScopeIdx])));
DebugInst->getExtSetKind() ==
SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
DebugInst->getExtSetKind() ==
- SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
+ SPIRVEIS_NonSemantic_Shader_DebugInfo_200) &&
"Unexpected extended instruction set");
auto It = DebugInstCache.find(DebugInst);
if (It != DebugInstCache.end())
return nullptr;
}
const std::string &getString(const SPIRVId Id);
+ SPIRVWord getConstantValueOrLiteral(const std::vector<SPIRVWord> &,
+ const SPIRVWord,
+ const SPIRVExtInstSetKind);
std::string findModuleProducer();
Optional<DIFile::ChecksumInfo<StringRef>> ParseChecksum(StringRef Text);
};
SPIRVEIS_Debug,
SPIRVEIS_OpenCL_DebugInfo_100,
SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
- SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
+ SPIRVEIS_NonSemantic_Shader_DebugInfo_200,
SPIRVEIS_Count,
};
add(SPIRVEIS_OpenCL_DebugInfo_100, "OpenCL.DebugInfo.100");
add(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
"NonSemantic.Shader.DebugInfo.100");
- add(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
- "NonSemantic.Kernel.DebugInfo.100");
+ add(SPIRVEIS_NonSemantic_Shader_DebugInfo_200,
+ "NonSemantic.Shader.DebugInfo.200");
}
typedef SPIRVMap<SPIRVExtInstSetKind, std::string> SPIRVBuiltinSetNameMap;
Inst->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100, SPIRVDebug::Scope) ||
Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
SPIRVDebug::Scope) ||
- Inst->isExtInst(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
+ Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200,
SPIRVDebug::Scope)) {
DebugScope = Inst;
} else if (Inst->isExtInst(SPIRVEIS_Debug, SPIRVDebug::NoScope) ||
SPIRVDebug::NoScope) ||
Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
SPIRVDebug::NoScope) ||
- Inst->isExtInst(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
+ Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_200,
SPIRVDebug::NoScope)) {
DebugScope = nullptr;
} else {
assert((ExtSetKind == SPIRVEIS_OpenCL || ExtSetKind == SPIRVEIS_Debug ||
ExtSetKind == SPIRVEIS_OpenCL_DebugInfo_100 ||
ExtSetKind == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
- ExtSetKind == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
+ ExtSetKind == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) &&
"not supported");
}
void encode(spv_ostream &O) const override {
case SPIRVEIS_Debug:
case SPIRVEIS_OpenCL_DebugInfo_100:
case SPIRVEIS_NonSemantic_Shader_DebugInfo_100:
- case SPIRVEIS_NonSemantic_Kernel_DebugInfo_100:
+ case SPIRVEIS_NonSemantic_Shader_DebugInfo_200:
getEncoder(O) << ExtOpDebug;
break;
default:
case SPIRVEIS_Debug:
case SPIRVEIS_OpenCL_DebugInfo_100:
case SPIRVEIS_NonSemantic_Shader_DebugInfo_100:
- case SPIRVEIS_NonSemantic_Kernel_DebugInfo_100:
+ case SPIRVEIS_NonSemantic_Shader_DebugInfo_200:
getDecoder(I) >> ExtOpDebug;
break;
default:
if ((EI->getExtSetKind() == SPIRVEIS_Debug ||
EI->getExtSetKind() == SPIRVEIS_OpenCL_DebugInfo_100 ||
EI->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
- EI->getExtSetKind() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
+ EI->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) &&
EI->getExtOp() != SPIRVDebug::Declare &&
EI->getExtOp() != SPIRVDebug::Value &&
EI->getExtOp() != SPIRVDebug::Scope &&
return SPIRVEIS_OpenCL_DebugInfo_100;
case DebugInfoEIS::NonSemantic_Shader_DebugInfo_100:
return SPIRVEIS_NonSemantic_Shader_DebugInfo_100;
- case DebugInfoEIS::NonSemantic_Kernel_DebugInfo_100:
- return SPIRVEIS_NonSemantic_Kernel_DebugInfo_100;
+ case DebugInfoEIS::NonSemantic_Shader_DebugInfo_200:
+ return SPIRVEIS_NonSemantic_Shader_DebugInfo_200;
}
assert(false && "Unexpected debug info EIS!");
return SPIRVEIS_Debug;
5 ExtInst 3 27 2 DebugInfoNone
7 ExtInst 3 30 2 DebugSource 29 27
-9 ExtInst 3 31 2 DebugCompileUnit 65536 4 30 21
+9 ExtInst 3 31 2 DebugCompileUnit 65536 4 30 21
7 ExtInst 3 32 2 DebugTypeFunction 0 27
8 ExtInst 3 35 2 DebugTypeBasic 33 34 3
7 ExtInst 3 36 2 DebugTypeArray 35 11 ; Count = 1000
4 Line 15 6 0
1 Return
-1 FunctionEnd
\ No newline at end of file
+1 FunctionEnd
--- /dev/null
+// Check for 2 things:
+// - After round trip translation function definition has !dbg metadata attached
+// specifically if -gline-tables-only was used for Clang
+// - Parent operand of DebugFunction is DebugCompileUnit, not an OpString, even
+// if in LLVM IR it points to a DIFile instead of DICompileUnit.
+
+// RUN: %clang_cc1 %s -cl-std=clc++ -emit-llvm-bc -triple spir -debug-info-kind=line-tables-only -O0 -o - | llvm-spirv -o %t.spv
+// RUN: llvm-spirv %t.spv --spirv-debug-info-version=nonsemantic-shader-100 -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM
+
+float foo(int i) {
+ return i * 3.14;
+}
+void kernel k() {
+ float a = foo(2);
+}
+
+// CHECK-SPIRV: String [[foo:[0-9]+]] "foo"
+// CHECK-SPIRV: String [[k:[0-9]+]] "k"
+// CHECK-SPIRV: [[CU:[0-9]+]] {{[0-9]+}} DebugCompileUnit
+// CHECK-SPIRV: DebugFunction [[foo]] {{.*}} [[CU]] {{.*}} [[foo_id:[0-9]+]] {{[0-9]+}} {{$}}
+// CHECK-SPIRV: DebugFunction [[k]] {{.*}} [[CU]] {{.*}} [[k_id:[0-9]+]] {{[0-9]+}} {{$}}
+
+// CHECK-SPIRV: Function {{[0-9]+}} [[foo_id]]
+// CHECK-LLVM: define spir_func float @_Z3fooi(i32 %i) #{{[0-9]+}} !dbg !{{[0-9]+}} {
+
+// CHECK-SPIRV: Function {{[0-9]+}} [[k_id]]
+// CHECK-LLVM: define spir_kernel void @k() #{{[0-9]+}} !dbg !{{[0-9]+}}
--- /dev/null
+; ModuleID = '/Volumes/Data/apple-internal/llvm/tools/clang/test/Modules/debug-info-moduleimport.m'
+; RUN: llvm-as < %s -o %t.bc
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 %t.bc -o %t.spv
+; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
+
+; RUN: llc -mtriple=x86_64-apple-macosx %t.ll -accel-tables=Dwarf -o %t -filetype=obj
+; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
+; RUN: llvm-dwarfdump -verify %t
+
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 %t.bc -spirv-text -o %t.spt
+; RUN: FileCheck %s --input-file %t.spt --check-prefix CHECK-SPIRV
+
+; CHECK: DW_TAG_compile_unit
+; CHECK-NOT: DW_TAG
+; CHECK: DW_TAG_module
+; CHECK-NEXT: DW_AT_name {{.*}}"DebugModule"
+; CHECK-NEXT: DW_AT_LLVM_config_macros {{.*}}"-DMODULES=0"
+; CHECK-NEXT: DW_AT_LLVM_include_path {{.*}}"/llvm/tools/clang/test/Modules/Inputs"
+; CHECK-NEXT: DW_AT_LLVM_apinotes {{.*}}"m.apinotes"
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "spir64-unknown-unknown"
+
+; CHECK-SPIRV-DAG: ExtInstImport [[#EISId:]] "NonSemantic.Shader.DebugInfo.200"
+; CHECK-SPIRV: String [[#FileName:]] "/llvm/tools/clang/test/Modules/<stdin>"
+; CHECK-SPIRV: String [[#EmptyStr:]] ""
+; CHECK-SPIRV: String [[#Name:]] "DebugModule"
+; CHECK-SPIRV: String [[#Defines:]] "-DMODULES=0"
+; CHECK-SPIRV: String [[#IncludePath:]] "/llvm/tools/clang/test/Modules/Inputs"
+; CHECK-SPIRV: String [[#ApiNotes:]] "m.apinotes"
+; CHECK-SPIRV: TypeInt [[#TypeInt32:]] 32 0
+; CHECK-SPIRV-DAG: Constant [[#TypeInt32]] [[#Constant0:]] 0
+; CHECK-SPIRV-DAG: Constant [[#TypeInt32]] [[#Version:]] 65536
+; CHECK-SPIRV-DAG: Constant [[#TypeInt32]] [[#DWARF:]] 4
+
+; CHECK-SPIRV: ExtInst [[#]] [[#Source:]] [[#]] DebugSource [[#FileName]]
+; CHECK-SPIRV: ExtInst [[#]] [[#Parent:]] [[#]] DebugCompileUnit [[#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]]
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "LLVM version 3.7.0", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !3, sysroot: "/")
+!1 = !DIFile(filename: "/llvm/tools/clang/test/Modules/<stdin>", directory: "/")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, file: !1, line: 5)
+!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", apinotes: "m.apinotes")
+!6 = !{i32 2, !"Dwarf Version", i32 4}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{!"LLVM version 3.7.0"}
--- /dev/null
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
+; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV: ExtInstImport [[#EISId:]] "NonSemantic.Shader.DebugInfo.200"
+; CHECK-SPIRV: String [[#StrGreet:]] ".str.GREETING"
+; CHECK-SPIRV: String [[#StrChar1:]] "CHARACTER_1"
+; 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: TypeVoid [[#TypeVoid:]]
+
+; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone
+; CHECK-SPIRV: [[#DataLocExpr:]] [[#EISId]] DebugExpression [[#]] [[#]] {{$}}
+; CHECK-SPIRV: [[#LengthAddrExpr:]] [[#EISId]] DebugExpression [[#]] [[#]] {{$}}
+
+; DebugTypeString NameId BaseTyId DataLocId SizeId LengthAddrId
+; CHECK-SPIRV: [[#EISId]] DebugTypeString [[#StrGreet]] [[#DINoneId]] [[#DataLocExpr]] [[#ConstZero]] [[#LengthAddrExpr]]
+; CHECK-SPIRV: [[#EISId]] DebugTypeString [[#StrChar1]] [[#DINoneId]] [[#DINoneId]] [[#Const80]] [[#DINoneId]]
+
+; CHECK-SPIRV-COUNT-2: [[#LengthAddrVar:]] [[#EISId]] DebugLocalVariable
+; CHECK-SPIRV-NEXT: [[#EISId]] DebugTypeString [[#StrChar2]] [[#DINoneId]] [[#DINoneId]] [[#ConstZero]] [[#LengthAddrVar]]
+; CHECK-SPIRV-COUNT-3: [[#LengthAddrVar1:]] [[#EISId]] DebugLocalVariable
+; CHECK-SPIRV-NEXT: [[#EISId]] DebugTypeString [[#StrChar3]] [[#DINoneId]] [[#DINoneId]] [[#ConstZero]] [[#LengthAddrVar1]]
+; 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-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: !DIStringType(name: "CHARACTER_2", stringLength: ![[#StrLenMD]])
+; CHECK-LLVM-DAG: ![[#StrLenMD1:]] = !DILocalVariable(name: "STRING2.len", scope: ![[#Scope]]
+; CHECK-LLVM-DAG: !DIStringType(name: "CHARACTER_3", stringLength: ![[#StrLenMD1]])
+
+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"
+
+%"QNCA_a0$i8*$rank0$" = type { ptr, i64, i64, i64, i64, i64 }
+
+@strlit = internal unnamed_addr constant [5 x i8] c"HELLO"
+@strlit.1 = internal unnamed_addr constant [3 x i8] c"TOM"
+@"hello_world_$GREETING" = internal global %"QNCA_a0$i8*$rank0$" zeroinitializer, !dbg !2
+@"hello_world_$NAME" = internal global [10 x i8] zeroinitializer, align 1, !dbg !10
+@0 = internal unnamed_addr constant i32 65536, align 4
+@1 = internal unnamed_addr constant i32 2, align 4
+@strlit.2 = internal unnamed_addr constant [2 x i8] c", "
+
+; Function Attrs: nounwind uwtable
+define void @MAIN__() local_unnamed_addr #0 !dbg !4{
+ %"hello_world_$GREETING_fetch.16" = load ptr, ptr @"hello_world_$GREETING", align 16, !dbg !20
+ %fetch.15 = load i64, ptr getelementptr inbounds (%"QNCA_a0$i8*$rank0$", ptr @"hello_world_$GREETING", i64 0, i32 1), align 8, !dbg !20
+ call void @llvm.dbg.value(metadata i64 %fetch.15, metadata !24, metadata !DIExpression()), !dbg !21
+ call void @llvm.dbg.value(metadata i64 %fetch.15, metadata !31, metadata !DIExpression()), !dbg !21
+ call void @llvm.dbg.value(metadata i64 10, metadata !28, metadata !DIExpression()), !dbg !21
+ call void @llvm.dbg.value(metadata i64 10, metadata !32, metadata !DIExpression()), !dbg !21
+ call void @llvm.dbg.declare(metadata ptr %"hello_world_$GREETING_fetch.16", metadata !26, metadata !DIExpression()), !dbg !36
+ call void @llvm.dbg.declare(metadata ptr @"hello_world_$NAME", metadata !29, metadata !DIExpression()), !dbg !37
+ ret void, !dbg !38
+}
+
+; Function Attrs: nofree nounwind uwtable
+define void @print_greeting_(ptr noalias readonly %"print_greeting_$STRING1", ptr noalias readonly %"print_greeting_$STRING2", i64 %"STRING1.len$val", i64 %"STRING2.len$val") local_unnamed_addr #1 !dbg !22 {
+alloca_1:
+ call void @llvm.dbg.value(metadata i64 %"STRING1.len$val", metadata !24, metadata !DIExpression()), !dbg !39
+ call void @llvm.dbg.value(metadata i64 %"STRING1.len$val", metadata !31, metadata !DIExpression()), !dbg !39
+ call void @llvm.dbg.value(metadata i64 %"STRING2.len$val", metadata !28, metadata !DIExpression()), !dbg !39
+ call void @llvm.dbg.value(metadata i64 %"STRING2.len$val", metadata !32, metadata !DIExpression()), !dbg !39
+ call void @llvm.dbg.declare(metadata ptr %"print_greeting_$STRING1", metadata !26, metadata !DIExpression()), !dbg !40
+ call void @llvm.dbg.declare(metadata ptr %"print_greeting_$STRING2", metadata !29, metadata !DIExpression()), !dbg !41
+ ret void, !dbg !42
+}
+
+; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #3
+
+attributes #0 = { nounwind uwtable }
+attributes #1 = { nofree nounwind uwtable}
+attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn }
+attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn }
+
+!llvm.module.flags = !{!18, !19}
+!llvm.dbg.cu = !{!8}
+
+!2 = !DIGlobalVariableExpression(var: !3, expr: !DIExpression())
+!3 = distinct !DIGlobalVariable(name: "greeting", linkageName: "hello_world_$GREETING", scope: !4, file: !5, line: 3, type: !14, isLocal: true, isDefinition: true)
+!4 = distinct !DISubprogram(name: "hello_world", linkageName: "MAIN__", scope: !5, file: !5, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !8, retainedNodes: !13)
+!5 = !DIFile(filename: "hello.f90", directory: "/dev/null")
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !5, producer: "fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)
+!9 = !{!2, !10}
+!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
+!11 = distinct !DIGlobalVariable(name: "name", linkageName: "hello_world_$NAME", scope: !4, file: !5, line: 2, type: !12, isLocal: true, isDefinition: true)
+!12 = !DIStringType(name: "CHARACTER_1", size: 80)
+!13 = !{}
+!14 = !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))
+!18 = !{i32 2, !"Debug Info Version", i32 3}
+!19 = !{i32 2, !"Dwarf Version", i32 4}
+!20 = !DILocation(line: 6, column: 23, scope: !4)
+!21 = !DILocation(line: 0, scope: !22, inlinedAt: !33)
+!22 = distinct !DISubprogram(name: "print_greeting", linkageName: "print_greeting_", scope: !5, file: !5, line: 9, type: !6, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !23)
+!23 = !{!24, !26, !28, !29, !31, !32}
+!24 = !DILocalVariable(name: "STRING1.len", scope: !22, type: !25, flags: DIFlagArtificial)
+!25 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
+!26 = !DILocalVariable(name: "string1", arg: 1, scope: !22, file: !5, line: 9, type: !27)
+!27 = !DIStringType(name: "CHARACTER_2", stringLength: !24)
+!28 = !DILocalVariable(name: "STRING2.len", scope: !22, type: !25, flags: DIFlagArtificial)
+!29 = !DILocalVariable(name: "string2", arg: 2, scope: !22, file: !5, line: 9, type: !30)
+!30 = !DIStringType(name: "CHARACTER_3", stringLength: !28)
+!31 = !DILocalVariable(name: "_string1", arg: 3, scope: !22, type: !25, flags: DIFlagArtificial)
+!32 = !DILocalVariable(name: "_string2", arg: 4, scope: !22, type: !25, flags: DIFlagArtificial)
+!33 = distinct !DILocation(line: 0, scope: !34, inlinedAt: !35)
+!34 = distinct !DISubprogram(name: "print_greeting_.t60p.t61p.t3v.t3v", linkageName: "print_greeting_.t60p.t61p.t3v.t3v", scope: !5, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !8, retainedNodes: !13, targetFuncName: "print_greeting_")
+!35 = distinct !DILocation(line: 6, column: 8, scope: !4)
+!36 = !DILocation(line: 9, column: 27, scope: !22, inlinedAt: !33)
+!37 = !DILocation(line: 9, column: 36, scope: !22, inlinedAt: !33)
+!38 = !DILocation(line: 7, column: 1, scope: !4)
+!39 = !DILocation(line: 0, scope: !22)
+!40 = !DILocation(line: 9, column: 27, scope: !22)
+!41 = !DILocation(line: 9, column: 36, scope: !22)
+!42 = !DILocation(line: 12, column: 1, scope: !22)
--- /dev/null
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
+; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV: ExtInstImport [[#EISId:]] "NonSemantic.Shader.DebugInfo.200"
+
+; CHECK-SPIRV: String [[#LocalVarNameId:]] "A$1$upperbound"
+; CHECK-SPIRV: TypeInt [[#TyInt64Id:]] 64 0
+; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1Id:]] 1 0
+; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1000Id:]] 1000 0
+; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone
+
+; CHECK-SPIRV: [[#DebugFuncId:]] [[#EISId]] DebugFunction
+; CHECK-SPIRV: [[#DebugTemplate:]] [[#EISId]] DebugTemplate [[#DebugFuncId]]
+; CHECK-SPIRV: [[#LocalVarId:]] [[#EISId]] DebugLocalVariable [[#LocalVarNameId]] [[#]] [[#]] [[#]] [[#]] [[#DebugTemplate]]
+; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#DINoneId]] [[#Constant1Id]] [[#LocalVarId]] [[#DINoneId]]
+
+; CHECK-SPIRV: [[#DIExprId:]] [[#EISId]] DebugExpression
+; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#DINoneId]] [[#DIExprId]] [[#DIExprId]] [[#DINoneId]]
+
+; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#Constant1000Id]] [[#Constant1Id]] [[#DINoneId]] [[#DINoneId]]
+
+; CHECK-LLVM: [[#Subrange1:]] = !DISubrange(lowerBound: 1, upperBound: ![[#UpperBound:]])
+; CHECK-LLVM: [[#UpperBound]] = !DILocalVariable(name: "A$1$upperbound"
+; CHECK-LLVM: !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression())
+; CHECK-LLVM: !DISubrange(count: 1000, lowerBound: 1)
+
+; 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"
+target triple = "spir64-unknown-unknown"
+
+%structtype = type { [72 x i1] }
+%"QNCA_a0$float" = type { float addrspace(4)*, i64, i64, i64, i64, i64, [1 x %structtype2] }
+%structtype2 = type { i64, i64, i64 }
+
+; Function Attrs: noinline nounwind
+define spir_kernel void @__omp_offloading_811_198142f_random_fill_sp_l25(i32 addrspace(1)* noalias %0, %structtype* byval(%structtype) %"ascast$val", [1000 x i32] addrspace(1)* noalias %"ascastB$val") #0 !kernel_arg_addr_space !9 !kernel_arg_access_qual !10 !kernel_arg_type !11 !kernel_arg_type_qual !12 !kernel_arg_base_type !11 {
+newFuncRoot:
+ %.ascast = bitcast %structtype* %"ascast$val" to %"QNCA_a0$float"*
+ call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !27
+ call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !42
+ call void @llvm.dbg.value(metadata [1000 x i32] addrspace(1)* %"ascastB$val", metadata !47, metadata !DIExpression(DW_OP_deref)), !dbg !51
+ call void @llvm.dbg.value(metadata i32 addrspace(1)* %0, metadata !54, metadata !DIExpression(DW_OP_deref)), !dbg !59
+ ret void
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline nounwind }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+!spirv.MemoryModel = !{!4}
+!opencl.enable.FP_CONTRACT = !{}
+!spirv.Source = !{!5}
+!opencl.spir.version = !{!6}
+!opencl.ocl.version = !{!6}
+!opencl.used.extensions = !{!7}
+!opencl.used.optional.core.features = !{!7}
+!spirv.Generator = !{!8}
+
+!0 = !{i32 7, !"Dwarf Version", i32 4}
+!1 = !{i32 2, !"Debug Info Version", i32 3}
+!2 = distinct !DICompileUnit(language: DW_LANG_OpenCL, file: !3, producer: "Fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
+!3 = !DIFile(filename: "f.f90", directory: "Fortran")
+!4 = !{i32 2, i32 2}
+!5 = !{i32 4, i32 200000}
+!6 = !{i32 2, i32 0}
+!7 = !{}
+!8 = !{i16 6, i16 14}
+!9 = !{i32 0}
+!10 = !{!"none"}
+!11 = !{!"structtype"}
+!12 = !{!""}
+!13 = !DILocalVariable(name: "a", scope: !14, file: !3, line: 15, type: !18)
+!14 = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split", scope: null, file: !3, line: 25, type: !15, scopeLine: 25, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !17)
+!15 = !DISubroutineType(types: !16)
+!16 = !{null}
+!17 = !{!13}
+!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
+!19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !20, size: 32, elements: !21)
+!20 = !DIBasicType(name: "REAL*4", size: 32, encoding: DW_ATE_float)
+!21 = !{!22}
+!22 = !DISubrange(lowerBound: 1, upperBound: !23)
+!23 = !DILocalVariable(name: "A$1$upperbound", scope: !24, type: !26, flags: DIFlagArtificial)
+!24 = distinct !DISubprogram(name: "random_fill_sp", linkageName: "random_fill_sp", scope: null, file: !3, line: 15, type: !15, scopeLine: 15, spFlags: DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !25)
+!25 = !{!23}
+!26 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
+!27 = !DILocation(line: 15, column: 67, scope: !14)
+!28 = !DILocalVariable(name: "a", scope: !29, file: !3, line: 15, type: !33)
+!29 = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split", scope: null, file: !3, line: 25, type: !30, scopeLine: 25, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !32)
+!30 = !DISubroutineType(types: !31)
+!31 = !{null}
+!32 = !{!28}
+!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !34, size: 64)
+!34 = !DICompositeType(tag: DW_TAG_array_type, baseType: !35, size: 32, elements: !36)
+!35 = !DIBasicType(name: "REAL*4", size: 32, encoding: DW_ATE_float)
+!36 = !{!37}
+!37 = !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression())
+!38 = !DILocalVariable(name: "A$1$upperbound", scope: !39, type: !41, flags: DIFlagArtificial)
+!39 = distinct !DISubprogram(name: "random_fill_sp", linkageName: "random_fill_sp", scope: null, file: !3, line: 15, type: !30, scopeLine: 15, spFlags: DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !40)
+!40 = !{!38}
+!41 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
+!42 = !DILocation(line: 15, column: 67, scope: !29)
+!43 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
+!44 = !{}
+!45 = !DISubroutineType(types: !44)
+!46 = distinct !DISubprogram(name: "test_target_map_array_default_IP_test_array_map_no_map_type_.DIR.OMP.TARGET.340.split", scope: !3, file: !3, line: 32, type: !45, scopeLine: 32, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2)
+!47 = !DILocalVariable(name: "compute_array", scope: !46, file: !3, line: 27, type: !48)
+!48 = !DICompositeType(tag: DW_TAG_array_type, baseType: !43, elements: !49)
+!49 = !{!50}
+!50 = !DISubrange(count: 1000, lowerBound: 1)
+!51 = !DILocation(line: 27, column: 24, scope: !46)
+!52 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 51, type: !53, scopeLine: 51, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2)
+!53 = !DISubroutineType(types: !7)
+!54 = !DILocalVariable(name: "isHost", scope: !52, file: !3, line: 34, type: !55)
+!55 = !DICompositeType(tag: DW_TAG_array_type, baseType: !56, elements: !57)
+!56 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!57 = !{!58}
+!58 = !DISubrange(count: -1)
+!59 = !DILocation(line: 34, column: 33, scope: !52)
--- /dev/null
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
+; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV-DAG: ExtInstImport [[#EISId:]] "NonSemantic.Shader.DebugInfo.200"
+; CHECK-SPIRV-DAG: String [[#Func:]] "foo_wrapper"
+; CHECK-SPIRV-DAG: String [[#TargetFunc:]] "_Z3foov"
+
+; CHECK-SPIRV-DAG: ExtInst [[#]] [[#DebugNone:]] [[#]] DebugInfoNone
+; CHECK-SPIRV-DAG: ExtInst [[#]] [[#]] [[#]] DebugFunction [[#Func]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#DebugNone]] [[#TargetFunc]]
+
+; 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")
+
+; 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"
+target triple = "spir64-unknown-unknown"
+
+define spir_func void @_Z11foo_wrapperv() !dbg !10 {
+ call void @_Z3foov(), !dbg !15
+ ret void, !dbg !16
+}
+
+declare spir_func void @_Z3foov()
+
+define spir_func void @_Z3boov() !dbg !17 {
+ call void @_Z11foo_wrapperv(), !dbg !18
+ ret void, !dbg !19
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 88bd2601c013e349fa907b3f878312a94e16e9f6)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/app/example.cpp", directory: "/app")
+!2 = !{i32 7, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 88bd2601c013e349fa907b3f878312a94e16e9f6)"}
+!10 = distinct !DISubprogram(name: "foo_wrapper", linkageName: "_Z11foo_wrapperv", scope: !11, file: !11, line: 3, type: !12, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14, targetFuncName: "_Z3foov")
+!11 = !DIFile(filename: "example.cpp", directory: "/app")
+!12 = !DISubroutineType(types: !13)
+!13 = !{null}
+!14 = !{}
+!15 = !DILocation(line: 4, column: 5, scope: !10)
+!16 = !DILocation(line: 5, column: 1, scope: !10)
+!17 = distinct !DISubprogram(name: "boo", linkageName: "_Z3boov", scope: !11, file: !11, line: 7, type: !12, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14)
+!18 = !DILocation(line: 8, column: 5, scope: !17)
+!19 = !DILocation(line: 9, column: 1, scope: !17)
--- /dev/null
+; RUN: llvm-as %s -o %t.bc
+; Translation shouldn't crash:
+; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
+
+; CHECK-LLVM: !DICompileUnit(language: DW_LANG_Fortran95
+; 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))
+; CHECK-LLVM: ![[#BaseT:]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
+; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
+; CHECK-LLVM: ![[#SubRange]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
+
+source_filename = "llvm-link"
+target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
+target triple = "spir64"
+
+!llvm.module.flags = !{!5, !6, !7, !8}
+!llvm.dbg.cu = !{!9}
+
+!0 = !{}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !10, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !0, globals: !0, imports: !22, splitDebugInlining: false, nameTableKind: None)
+!10 = !DIFile(filename: "declare_target_subroutine.F90", directory: "/test")
+!19 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
+!22 = !{!23}
+!23 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !24, entity: !34, file: !10, line: 24)
+!24 = distinct !DISubprogram(name: "declare_target_subroutine", linkageName: "MAIN__", scope: !10, file: !10, line: 23, type: !25, scopeLine: 23, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !9, retainedNodes: !27)
+!25 = !DISubroutineType(types: !26)
+!26 = !{null}
+!27 = !{!30}
+!30 = !DILocalVariable(name: "a", scope: !24, file: !10, line: 28, type: !31)
+!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, elements: !32, 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))
+!32 = !{!33}
+!33 = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
+!34 = !DIModule(scope: !24, name: "iso_fortran_env", isDecl: true)
--- /dev/null
+;; The test checks, that Fortran dynamic arrays are being correctly represented
+;; by SPIR-V debug information
+;; Unlike 'static' arrays dynamic can have following parameters of
+;; DICompositeType metadata with DW_TAG_array_type tag:
+;; Data Location, Associated, Allocated and Rank which can be represented
+;; by either DIExpression or DIVariable (both local and global).
+;; This test if for expression representation.
+;; FortranDynamicArrayVar.ll is for variable representation.
+
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-200 -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
+
+; CHECK-SPIRV-DAG: ExtInstImport [[#Import:]] "NonSemantic.Shader.DebugInfo.200"
+; CHECK-SPIRV-DAG: String [[#BasicTName:]] "INTEGER*4"
+; CHECK-SPIRV-DAG: TypeInt [[#Int32T:]] 32 0
+; CHECK-SPIRV-DAG: Constant [[#Int32T]] [[#IntConst:]] 32
+; CHECK-SPIRV-DAG: Constant [[#Int32T]] [[#Flag:]] 4
+; CHECK-SPIRV-DAG: TypeVoid [[#VoidT:]]
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgInfoNone:]] [[#Import]] DebugInfoNone
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#ArrayBasicT:]] [[#Import]] DebugTypeBasic [[#BasicTName]] [[#IntConst]] [[#Flag]]
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLocation:]] [[#Import]] DebugExpression [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprAssociated:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLowerBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprUpperBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprCount:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgSubRangeId:]] [[#Import]] DebugTypeSubrange [[#DbgInfoNone]] [[#DbgExprLowerBound]] [[#DbgExprUpperBound]] [[#DbgExprCount]]
+; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgArrayId:]] [[#Import]] DebugTypeArrayDynamic [[#ArrayBasicT]] [[#DbgExprLocation]] [[#DbgExprAssociated]] [[#DbgInfoNone]] [[#DbgInfoNone]] [[#DbgSubRangeId]]
+
+; CHECK-LLVM: %[[#Array:]] = alloca
+; CHECK-LLVM: call void @llvm.dbg.value(metadata ptr %[[#Array]], metadata ![[#DbgLVar:]]
+; CHECK-LLVM: ![[#DbgLVar]] = !DILocalVariable(name: "pint", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#DbgLVarT:]])
+; CHECK-LLVM: ![[#DbgLVarT]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#DbgArrayT:]], size: 64)
+; CHECK-LLVM: ![[#DbgArrayT]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#DbgArrayBaseT:]], 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))
+; CHECK-LLVM: ![[#DbgArrayBaseT]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
+; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
+; CHECK-LLVM: ![[#SubRange]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
+
+
+; ModuleID = 'reproducer.ll'
+source_filename = "test.f90"
+target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
+target triple = "spir64"
+
+%qnca = type { i32 addrspace(4)*, i64, i64, i64, i64, i64, [1 x { i64, i64, i64 }] }
+
+; Function Attrs: noinline nounwind optnone
+define weak dso_local spir_kernel void @TEST() #0 !dbg !5 {
+newFuncRoot:
+ %0 = alloca %qnca, align 8
+ call void @llvm.dbg.value(metadata %qnca* %0, metadata !8, metadata !DIExpression()), !dbg !14
+ ret void
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline nounwind optnone }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+!spirv.Source = !{!4}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !{i32 2, !"Dwarf Version", i32 4}
+!2 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: "fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
+!3 = !DIFile(filename: "test.f90", directory: "/path/to")
+!4 = !{i32 4, i32 200000}
+!5 = distinct !DISubprogram(name: "test", linkageName: "MAIN__", scope: !3, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !DILocalVariable(name: "pint", scope: !5, file: !3, line: 3, type: !9)
+!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
+!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, elements: !12, 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))
+!11 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
+!12 = !{!13}
+!13 = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
+!14 = !DILocation(line: 1, scope: !5)
+
--- /dev/null
+;; DebugInfo/dwarfdump-dataLocationVar.ll from llvm.org is used as base for this test
+;; The test checks, that Fortran dynamic arrays are being correctly represented
+;; by SPIR-V debug information
+;; Unlike 'static' arrays dynamic can have following parameters of
+;; DICompositeType metadata with DW_TAG_array_type tag:
+;; Data Location, Associated, Allocated and Rank which can be represented
+;; by either DIExpression or DIVariable (both local and global).
+;; This test if for variable representation.
+;; FortranDynamicArrayVar.ll is for expression representation.
+
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-200 -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-shader-200
+; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
+
+;; Major SPIR-V checks are done in FortranDynamicArrayExpr.ll
+; CHECK-SPIRV: ExtInst [[#]] [[#DbgLVarId:]] [[#]] DebugLocalVariable [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] {{$}}
+; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugTypeArrayDynamic [[#]] [[#DbgLVarId]] [[#]] [[#]] [[#]] [[#]]
+
+; CHECK-LLVM: %[[#Ptr:]] = alloca ptr
+; CHECK-LLVM: %[[#Array:]] = alloca [16 x i64]
+; CHECK-LLVM: call void @llvm.dbg.declare(metadata ptr %[[#Array]], metadata ![[#DbgLVarArray:]]
+; CHECK-LLVM: call void @llvm.dbg.declare(metadata ptr %[[#Ptr]], metadata ![[#DbgLVarPtr:]]
+
+; CHECK-LLVM: ![[#DbgLVarPtr:]] = !DILocalVariable(scope: ![[#]], file: ![[#]], type: ![[#DbgPtrT:]], flags: DIFlagArtificial)
+; CHECK-LLVM: ![[#DbgPtrT:]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#DbgBasicT:]], size: 64)
+; CHECK-LLVM: ![[#DbgBasicT]] = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
+; CHECK-LLVM: ![[#DbgLVarArray]] = !DILocalVariable(name: "arr", scope: ![[#]], file: ![[#]], type: ![[#DbgArrayT:]])
+; CHECK-LLVM: ![[#DbgArrayT]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#DbgBasicT]], size: 608, elements: ![[#Elements:]], dataLocation: ![[#DbgLVarPtr]])
+; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
+; CHECK-LLVM: ![[#SubRange]] = !DISubrange(count: 19, lowerBound: 2)
+
+; ModuleID = 'fortsubrange.ll'
+source_filename = "fortsubrange.ll"
+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"
+
+define spir_func void @foo() !dbg !5 {
+L.entry:
+ %0 = alloca ptr, align 8
+ %1 = alloca [16 x i64], align 8
+ call void @llvm.dbg.declare(metadata ptr %1, metadata !8, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.declare(metadata ptr %0, metadata !14, metadata !DIExpression()), !dbg !16
+ ret void, !dbg !17
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+
+!0 = !{i32 2, !"Dwarf Version", i32 4}
+!1 = !{i32 2, !"Debug Info Version", i32 3}
+!2 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: " F95 Flang - 1.5 2017-05-01", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !4, imports: !4)
+!3 = !DIFile(filename: "fortsubrange.f90", directory: "/dir")
+!4 = !{}
+!5 = distinct !DISubprogram(name: "main", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
+!6 = !DISubroutineType(cc: DW_CC_program, types: !7)
+!7 = !{null}
+!8 = !DILocalVariable(name: "arr", scope: !9, file: !3, type: !10)
+!9 = !DILexicalBlock(scope: !5, file: !3, line: 1, column: 1)
+!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 32, align: 32, elements: !12, dataLocation: !14)
+!11 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
+!12 = !{!13}
+!13 = !DISubrange(count: 19, lowerBound: 2)
+!14 = distinct !DILocalVariable(scope: !9, file: !3, type: !15, flags: DIFlagArtificial)
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32, align: 32)
+!16 = !DILocation(line: 0, scope: !9)
+!17 = !DILocation(line: 6, column: 1, scope: !9)
--- /dev/null
+; Test checks that DW_LANG_C99, DW_LANG_OpenCL, and all DW_LANG_C_plus_plus_X are mapped to
+; appropriate SourceLanguages in SPIRV when the extended debug info is enabled.
+
+; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C99/' %s | llvm-as - -o %t.bc
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-C99
+
+; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_OpenCL/' %s | llvm-as - -o %t.bc
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-OPENCLC
+
+; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C_plus_plus/' %s | llvm-as - -o %t.bc
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-CPP
+
+; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C_plus_plus_14/' %s | llvm-as - -o %t.bc
+; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-CPP14
+
+; CHECK-C99: Constant [[#]] [[#Constant:]] 109
+; CHECK-C99: DebugCompileUnit [[#]] [[#]] [[#]] [[#Constant]]
+; CHECK-OPENCLC: Constant [[#]] [[#Constant:]] 3
+; CHECK-OPENCLC: DebugCompileUnit [[#]] [[#]] [[#]] [[#Constant]]
+; CHECK-CPP: Constant [[#]] [[#Constant:]] 111
+; CHECK-CPP: DebugCompileUnit [[#]] [[#]] [[#]] [[#Constant]]
+; CHECK-CPP14: Constant [[#]] [[#Constant:]] 114
+; CHECK-CPP14: DebugCompileUnit [[#]] [[#]] [[#]] [[#Constant]]
+
+target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+target triple = "spir64-unknown-unknown"
+
+define dso_local spir_kernel void @func() local_unnamed_addr !dbg !7 !kernel_arg_addr_space !2 !kernel_arg_access_qual !2 !kernel_arg_type !2 !kernel_arg_base_type !2 !kernel_arg_type_qual !2 {
+entry:
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+
+!0 = distinct !DICompileUnit(language: INPUT_LANGUAGE, file: !1)
+!1 = !DIFile(filename: "test.cl", directory: "/tmp", checksumkind: CSK_MD5, checksum: "18aa9ce738eaafc7b7b7181c19092815")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 2, i32 0}
+!7 = distinct !DISubprogram(name: "func", scope: !8, file: !8, line: 1, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "test.cl", directory: "/tmp", checksumkind: CSK_MD5, checksum: "18aa9ce738eaafc7b7b7181c19092815")
+++ /dev/null
-; ModuleID = '/Volumes/Data/apple-internal/llvm/tools/clang/test/Modules/debug-info-moduleimport.m'
-; RUN: llvm-as < %s -o %t.bc
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 %t.bc -o %t.spv
-; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
-
-; RUN: llc -mtriple=x86_64-apple-macosx %t.ll -accel-tables=Dwarf -o %t -filetype=obj
-; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
-; RUN: llvm-dwarfdump -verify %t
-
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 %t.bc -spirv-text -o %t.spt
-; RUN: FileCheck %s --input-file %t.spt --check-prefix CHECK-SPIRV
-
-; CHECK: DW_TAG_compile_unit
-; CHECK-NOT: DW_TAG
-; CHECK: DW_TAG_module
-; CHECK-NEXT: DW_AT_name {{.*}}"DebugModule"
-; CHECK-NEXT: DW_AT_LLVM_config_macros {{.*}}"-DMODULES=0"
-; CHECK-NEXT: DW_AT_LLVM_include_path {{.*}}"/llvm/tools/clang/test/Modules/Inputs"
-; CHECK-NEXT: DW_AT_LLVM_apinotes {{.*}}"m.apinotes"
-
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "spir64-unknown-unknown"
-
-; CHECK-SPIRV-DAG: ExtInstImport [[#EISId:]] "NonSemantic.Kernel.DebugInfo.100"
-; CHECK-SPIRV: String [[#FileName:]] "/llvm/tools/clang/test/Modules/<stdin>"
-; CHECK-SPIRV: String [[#EmptyStr:]] ""
-; CHECK-SPIRV: String [[#Name:]] "DebugModule"
-; CHECK-SPIRV: String [[#Defines:]] "-DMODULES=0"
-; CHECK-SPIRV: String [[#IncludePath:]] "/llvm/tools/clang/test/Modules/Inputs"
-; CHECK-SPIRV: String [[#ApiNotes:]] "m.apinotes"
-; CHECK-SPIRV: TypeInt [[#TypeInt32:]] 32 0
-; CHECK-SPIRV: Constant [[#TypeInt32]] [[#Constant0:]] 0
-
-; CHECK-SPIRV: ExtInst [[#]] [[#Source:]] [[#]] DebugSource [[#FileName]]
-; CHECK-SPIRV: ExtInst [[#]] [[#Parent:]] [[#]] DebugCompileUnit 65536 4
-; 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]]
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!6, !7}
-!llvm.ident = !{!8}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "LLVM version 3.7.0", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !3, sysroot: "/")
-!1 = !DIFile(filename: "/llvm/tools/clang/test/Modules/<stdin>", directory: "/")
-!2 = !{}
-!3 = !{!4}
-!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, file: !1, line: 5)
-!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", apinotes: "m.apinotes")
-!6 = !{i32 2, !"Dwarf Version", i32 4}
-!7 = !{i32 2, !"Debug Info Version", i32 3}
-!8 = !{!"LLVM version 3.7.0"}
+++ /dev/null
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
-; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV: ExtInstImport [[#EISId:]] "NonSemantic.Kernel.DebugInfo.100"
-; CHECK-SPIRV: String [[#StrGreet:]] ".str.GREETING"
-; CHECK-SPIRV: String [[#StrChar1:]] "CHARACTER_1"
-; 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: TypeVoid [[#TypeVoid:]]
-
-; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone
-; CHECK-SPIRV: [[#DataLocExpr:]] [[#EISId]] DebugExpression [[#]] [[#]] {{$}}
-; CHECK-SPIRV: [[#LengthAddrExpr:]] [[#EISId]] DebugExpression [[#]] [[#]] {{$}}
-
-; DebugTypeString NameId BaseTyId DataLocId SizeId LengthAddrId
-; CHECK-SPIRV: [[#EISId]] DebugTypeString [[#StrGreet]] [[#DINoneId]] [[#DataLocExpr]] [[#ConstZero]] [[#LengthAddrExpr]]
-; CHECK-SPIRV: [[#EISId]] DebugTypeString [[#StrChar1]] [[#DINoneId]] [[#DINoneId]] [[#Const80]] [[#DINoneId]]
-
-; CHECK-SPIRV-COUNT-2: [[#LengthAddrVar:]] [[#EISId]] DebugLocalVariable
-; CHECK-SPIRV-NEXT: [[#EISId]] DebugTypeString [[#StrChar2]] [[#DINoneId]] [[#DINoneId]] [[#ConstZero]] [[#LengthAddrVar]]
-; CHECK-SPIRV-COUNT-3: [[#LengthAddrVar1:]] [[#EISId]] DebugLocalVariable
-; CHECK-SPIRV-NEXT: [[#EISId]] DebugTypeString [[#StrChar3]] [[#DINoneId]] [[#DINoneId]] [[#ConstZero]] [[#LengthAddrVar1]]
-; 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-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: !DIStringType(name: "CHARACTER_2", stringLength: ![[#StrLenMD]])
-; CHECK-LLVM-DAG: ![[#StrLenMD1:]] = !DILocalVariable(name: "STRING2.len", scope: ![[#Scope]]
-; CHECK-LLVM-DAG: !DIStringType(name: "CHARACTER_3", stringLength: ![[#StrLenMD1]])
-
-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"
-
-%"QNCA_a0$i8*$rank0$" = type { ptr, i64, i64, i64, i64, i64 }
-
-@strlit = internal unnamed_addr constant [5 x i8] c"HELLO"
-@strlit.1 = internal unnamed_addr constant [3 x i8] c"TOM"
-@"hello_world_$GREETING" = internal global %"QNCA_a0$i8*$rank0$" zeroinitializer, !dbg !2
-@"hello_world_$NAME" = internal global [10 x i8] zeroinitializer, align 1, !dbg !10
-@0 = internal unnamed_addr constant i32 65536, align 4
-@1 = internal unnamed_addr constant i32 2, align 4
-@strlit.2 = internal unnamed_addr constant [2 x i8] c", "
-
-; Function Attrs: nounwind uwtable
-define void @MAIN__() local_unnamed_addr #0 !dbg !4{
- %"hello_world_$GREETING_fetch.16" = load ptr, ptr @"hello_world_$GREETING", align 16, !dbg !20
- %fetch.15 = load i64, ptr getelementptr inbounds (%"QNCA_a0$i8*$rank0$", ptr @"hello_world_$GREETING", i64 0, i32 1), align 8, !dbg !20
- call void @llvm.dbg.value(metadata i64 %fetch.15, metadata !24, metadata !DIExpression()), !dbg !21
- call void @llvm.dbg.value(metadata i64 %fetch.15, metadata !31, metadata !DIExpression()), !dbg !21
- call void @llvm.dbg.value(metadata i64 10, metadata !28, metadata !DIExpression()), !dbg !21
- call void @llvm.dbg.value(metadata i64 10, metadata !32, metadata !DIExpression()), !dbg !21
- call void @llvm.dbg.declare(metadata ptr %"hello_world_$GREETING_fetch.16", metadata !26, metadata !DIExpression()), !dbg !36
- call void @llvm.dbg.declare(metadata ptr @"hello_world_$NAME", metadata !29, metadata !DIExpression()), !dbg !37
- ret void, !dbg !38
-}
-
-; Function Attrs: nofree nounwind uwtable
-define void @print_greeting_(ptr noalias readonly %"print_greeting_$STRING1", ptr noalias readonly %"print_greeting_$STRING2", i64 %"STRING1.len$val", i64 %"STRING2.len$val") local_unnamed_addr #1 !dbg !22 {
-alloca_1:
- call void @llvm.dbg.value(metadata i64 %"STRING1.len$val", metadata !24, metadata !DIExpression()), !dbg !39
- call void @llvm.dbg.value(metadata i64 %"STRING1.len$val", metadata !31, metadata !DIExpression()), !dbg !39
- call void @llvm.dbg.value(metadata i64 %"STRING2.len$val", metadata !28, metadata !DIExpression()), !dbg !39
- call void @llvm.dbg.value(metadata i64 %"STRING2.len$val", metadata !32, metadata !DIExpression()), !dbg !39
- call void @llvm.dbg.declare(metadata ptr %"print_greeting_$STRING1", metadata !26, metadata !DIExpression()), !dbg !40
- call void @llvm.dbg.declare(metadata ptr %"print_greeting_$STRING2", metadata !29, metadata !DIExpression()), !dbg !41
- ret void, !dbg !42
-}
-
-; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn
-declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
-
-; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn
-declare void @llvm.dbg.value(metadata, metadata, metadata) #3
-
-attributes #0 = { nounwind uwtable }
-attributes #1 = { nofree nounwind uwtable}
-attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn }
-attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn }
-
-!llvm.module.flags = !{!18, !19}
-!llvm.dbg.cu = !{!8}
-
-!2 = !DIGlobalVariableExpression(var: !3, expr: !DIExpression())
-!3 = distinct !DIGlobalVariable(name: "greeting", linkageName: "hello_world_$GREETING", scope: !4, file: !5, line: 3, type: !14, isLocal: true, isDefinition: true)
-!4 = distinct !DISubprogram(name: "hello_world", linkageName: "MAIN__", scope: !5, file: !5, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !8, retainedNodes: !13)
-!5 = !DIFile(filename: "hello.f90", directory: "/dev/null")
-!6 = !DISubroutineType(types: !7)
-!7 = !{null}
-!8 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !5, producer: "fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)
-!9 = !{!2, !10}
-!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
-!11 = distinct !DIGlobalVariable(name: "name", linkageName: "hello_world_$NAME", scope: !4, file: !5, line: 2, type: !12, isLocal: true, isDefinition: true)
-!12 = !DIStringType(name: "CHARACTER_1", size: 80)
-!13 = !{}
-!14 = !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))
-!18 = !{i32 2, !"Debug Info Version", i32 3}
-!19 = !{i32 2, !"Dwarf Version", i32 4}
-!20 = !DILocation(line: 6, column: 23, scope: !4)
-!21 = !DILocation(line: 0, scope: !22, inlinedAt: !33)
-!22 = distinct !DISubprogram(name: "print_greeting", linkageName: "print_greeting_", scope: !5, file: !5, line: 9, type: !6, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !23)
-!23 = !{!24, !26, !28, !29, !31, !32}
-!24 = !DILocalVariable(name: "STRING1.len", scope: !22, type: !25, flags: DIFlagArtificial)
-!25 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
-!26 = !DILocalVariable(name: "string1", arg: 1, scope: !22, file: !5, line: 9, type: !27)
-!27 = !DIStringType(name: "CHARACTER_2", stringLength: !24)
-!28 = !DILocalVariable(name: "STRING2.len", scope: !22, type: !25, flags: DIFlagArtificial)
-!29 = !DILocalVariable(name: "string2", arg: 2, scope: !22, file: !5, line: 9, type: !30)
-!30 = !DIStringType(name: "CHARACTER_3", stringLength: !28)
-!31 = !DILocalVariable(name: "_string1", arg: 3, scope: !22, type: !25, flags: DIFlagArtificial)
-!32 = !DILocalVariable(name: "_string2", arg: 4, scope: !22, type: !25, flags: DIFlagArtificial)
-!33 = distinct !DILocation(line: 0, scope: !34, inlinedAt: !35)
-!34 = distinct !DISubprogram(name: "print_greeting_.t60p.t61p.t3v.t3v", linkageName: "print_greeting_.t60p.t61p.t3v.t3v", scope: !5, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !8, retainedNodes: !13, targetFuncName: "print_greeting_")
-!35 = distinct !DILocation(line: 6, column: 8, scope: !4)
-!36 = !DILocation(line: 9, column: 27, scope: !22, inlinedAt: !33)
-!37 = !DILocation(line: 9, column: 36, scope: !22, inlinedAt: !33)
-!38 = !DILocation(line: 7, column: 1, scope: !4)
-!39 = !DILocation(line: 0, scope: !22)
-!40 = !DILocation(line: 9, column: 27, scope: !22)
-!41 = !DILocation(line: 9, column: 36, scope: !22)
-!42 = !DILocation(line: 12, column: 1, scope: !22)
+++ /dev/null
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
-; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV: ExtInstImport [[#EISId:]] "NonSemantic.Kernel.DebugInfo.100"
-
-; CHECK-SPIRV: String [[#LocalVarNameId:]] "A$1$upperbound"
-; CHECK-SPIRV: TypeInt [[#TyInt64Id:]] 64 0
-; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1Id:]] 1 0
-; CHECK-SPIRV-DAG: Constant [[#TyInt64Id]] [[#Constant1000Id:]] 1000 0
-; CHECK-SPIRV: [[#DINoneId:]] [[#EISId]] DebugInfoNone
-
-; CHECK-SPIRV: [[#DebugFuncId:]] [[#EISId]] DebugFunction
-; CHECK-SPIRV: [[#DebugTemplate:]] [[#EISId]] DebugTemplate [[#DebugFuncId]]
-; CHECK-SPIRV: [[#LocalVarId:]] [[#EISId]] DebugLocalVariable [[#LocalVarNameId]] [[#]] [[#]] [[#]] [[#]] [[#DebugTemplate]]
-; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#DINoneId]] [[#Constant1Id]] [[#LocalVarId]] [[#DINoneId]]
-
-; CHECK-SPIRV: [[#DIExprId:]] [[#EISId]] DebugExpression
-; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#DINoneId]] [[#DIExprId]] [[#DIExprId]] [[#DINoneId]]
-
-; CHECK-SPIRV: [[#EISId]] DebugTypeSubrange [[#Constant1000Id]] [[#Constant1Id]] [[#DINoneId]] [[#DINoneId]]
-
-; CHECK-LLVM: [[#Subrange1:]] = !DISubrange(lowerBound: 1, upperBound: ![[#UpperBound:]])
-; CHECK-LLVM: [[#UpperBound]] = !DILocalVariable(name: "A$1$upperbound"
-; CHECK-LLVM: !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression())
-; CHECK-LLVM: !DISubrange(count: 1000, lowerBound: 1)
-
-; 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"
-target triple = "spir64-unknown-unknown"
-
-%structtype = type { [72 x i1] }
-%"QNCA_a0$float" = type { float addrspace(4)*, i64, i64, i64, i64, i64, [1 x %structtype2] }
-%structtype2 = type { i64, i64, i64 }
-
-; Function Attrs: noinline nounwind
-define spir_kernel void @__omp_offloading_811_198142f_random_fill_sp_l25(i32 addrspace(1)* noalias %0, %structtype* byval(%structtype) %"ascast$val", [1000 x i32] addrspace(1)* noalias %"ascastB$val") #0 !kernel_arg_addr_space !9 !kernel_arg_access_qual !10 !kernel_arg_type !11 !kernel_arg_type_qual !12 !kernel_arg_base_type !11 {
-newFuncRoot:
- %.ascast = bitcast %structtype* %"ascast$val" to %"QNCA_a0$float"*
- call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !27
- call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !42
- call void @llvm.dbg.value(metadata [1000 x i32] addrspace(1)* %"ascastB$val", metadata !47, metadata !DIExpression(DW_OP_deref)), !dbg !51
- call void @llvm.dbg.value(metadata i32 addrspace(1)* %0, metadata !54, metadata !DIExpression(DW_OP_deref)), !dbg !59
- ret void
-}
-
-; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
-declare void @llvm.dbg.value(metadata, metadata, metadata) #1
-
-attributes #0 = { noinline nounwind }
-attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
-
-!llvm.module.flags = !{!0, !1}
-!llvm.dbg.cu = !{!2}
-!spirv.MemoryModel = !{!4}
-!opencl.enable.FP_CONTRACT = !{}
-!spirv.Source = !{!5}
-!opencl.spir.version = !{!6}
-!opencl.ocl.version = !{!6}
-!opencl.used.extensions = !{!7}
-!opencl.used.optional.core.features = !{!7}
-!spirv.Generator = !{!8}
-
-!0 = !{i32 7, !"Dwarf Version", i32 4}
-!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DICompileUnit(language: DW_LANG_OpenCL, file: !3, producer: "Fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
-!3 = !DIFile(filename: "f.f90", directory: "Fortran")
-!4 = !{i32 2, i32 2}
-!5 = !{i32 4, i32 200000}
-!6 = !{i32 2, i32 0}
-!7 = !{}
-!8 = !{i16 6, i16 14}
-!9 = !{i32 0}
-!10 = !{!"none"}
-!11 = !{!"structtype"}
-!12 = !{!""}
-!13 = !DILocalVariable(name: "a", scope: !14, file: !3, line: 15, type: !18)
-!14 = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split", scope: null, file: !3, line: 25, type: !15, scopeLine: 25, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !17)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null}
-!17 = !{!13}
-!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
-!19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !20, size: 32, elements: !21)
-!20 = !DIBasicType(name: "REAL*4", size: 32, encoding: DW_ATE_float)
-!21 = !{!22}
-!22 = !DISubrange(lowerBound: 1, upperBound: !23)
-!23 = !DILocalVariable(name: "A$1$upperbound", scope: !24, type: !26, flags: DIFlagArtificial)
-!24 = distinct !DISubprogram(name: "random_fill_sp", linkageName: "random_fill_sp", scope: null, file: !3, line: 15, type: !15, scopeLine: 15, spFlags: DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !25)
-!25 = !{!23}
-!26 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
-!27 = !DILocation(line: 15, column: 67, scope: !14)
-!28 = !DILocalVariable(name: "a", scope: !29, file: !3, line: 15, type: !33)
-!29 = distinct !DISubprogram(name: "random_fill_sp.DIR.OMP.TARGET.8.split.split.split.split", scope: null, file: !3, line: 25, type: !30, scopeLine: 25, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !32)
-!30 = !DISubroutineType(types: !31)
-!31 = !{null}
-!32 = !{!28}
-!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !34, size: 64)
-!34 = !DICompositeType(tag: DW_TAG_array_type, baseType: !35, size: 32, elements: !36)
-!35 = !DIBasicType(name: "REAL*4", size: 32, encoding: DW_ATE_float)
-!36 = !{!37}
-!37 = !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression())
-!38 = !DILocalVariable(name: "A$1$upperbound", scope: !39, type: !41, flags: DIFlagArtificial)
-!39 = distinct !DISubprogram(name: "random_fill_sp", linkageName: "random_fill_sp", scope: null, file: !3, line: 15, type: !30, scopeLine: 15, spFlags: DISPFlagDefinition, unit: !2, templateParams: !7, retainedNodes: !40)
-!40 = !{!38}
-!41 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
-!42 = !DILocation(line: 15, column: 67, scope: !29)
-!43 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
-!44 = !{}
-!45 = !DISubroutineType(types: !44)
-!46 = distinct !DISubprogram(name: "test_target_map_array_default_IP_test_array_map_no_map_type_.DIR.OMP.TARGET.340.split", scope: !3, file: !3, line: 32, type: !45, scopeLine: 32, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2)
-!47 = !DILocalVariable(name: "compute_array", scope: !46, file: !3, line: 27, type: !48)
-!48 = !DICompositeType(tag: DW_TAG_array_type, baseType: !43, elements: !49)
-!49 = !{!50}
-!50 = !DISubrange(count: 1000, lowerBound: 1)
-!51 = !DILocation(line: 27, column: 24, scope: !46)
-!52 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 51, type: !53, scopeLine: 51, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2)
-!53 = !DISubroutineType(types: !7)
-!54 = !DILocalVariable(name: "isHost", scope: !52, file: !3, line: 34, type: !55)
-!55 = !DICompositeType(tag: DW_TAG_array_type, baseType: !56, elements: !57)
-!56 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!57 = !{!58}
-!58 = !DISubrange(count: -1)
-!59 = !DILocation(line: 34, column: 33, scope: !52)
+++ /dev/null
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv -spirv-text %t.bc -o %t.spt --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
-; RUN: llvm-spirv -to-binary %t.spt -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-SPIRV-DAG: ExtInstImport [[#EISId:]] "NonSemantic.Kernel.DebugInfo.100"
-; CHECK-SPIRV-DAG: String [[#Func:]] "foo_wrapper"
-; CHECK-SPIRV-DAG: String [[#TargetFunc:]] "_Z3foov"
-
-; CHECK-SPIRV-DAG: ExtInst [[#]] [[#DebugNone:]] [[#]] DebugInfoNone
-; CHECK-SPIRV-DAG: ExtInst [[#]] [[#]] [[#]] DebugFunction [[#Func]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#DebugNone]] [[#TargetFunc]]
-
-; 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")
-
-; 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"
-target triple = "spir64-unknown-unknown"
-
-define spir_func void @_Z11foo_wrapperv() !dbg !10 {
- call void @_Z3foov(), !dbg !15
- ret void, !dbg !16
-}
-
-declare spir_func void @_Z3foov()
-
-define spir_func void @_Z3boov() !dbg !17 {
- call void @_Z11foo_wrapperv(), !dbg !18
- ret void, !dbg !19
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
-!llvm.ident = !{!9}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0 (https://github.com/llvm/llvm-project.git 88bd2601c013e349fa907b3f878312a94e16e9f6)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "/app/example.cpp", directory: "/app")
-!2 = !{i32 7, !"Dwarf Version", i32 4}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = !{i32 1, !"wchar_size", i32 4}
-!5 = !{i32 8, !"PIC Level", i32 2}
-!6 = !{i32 7, !"PIE Level", i32 2}
-!7 = !{i32 7, !"uwtable", i32 2}
-!8 = !{i32 7, !"frame-pointer", i32 2}
-!9 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 88bd2601c013e349fa907b3f878312a94e16e9f6)"}
-!10 = distinct !DISubprogram(name: "foo_wrapper", linkageName: "_Z11foo_wrapperv", scope: !11, file: !11, line: 3, type: !12, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14, targetFuncName: "_Z3foov")
-!11 = !DIFile(filename: "example.cpp", directory: "/app")
-!12 = !DISubroutineType(types: !13)
-!13 = !{null}
-!14 = !{}
-!15 = !DILocation(line: 4, column: 5, scope: !10)
-!16 = !DILocation(line: 5, column: 1, scope: !10)
-!17 = distinct !DISubprogram(name: "boo", linkageName: "_Z3boov", scope: !11, file: !11, line: 7, type: !12, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14)
-!18 = !DILocation(line: 8, column: 5, scope: !17)
-!19 = !DILocation(line: 9, column: 1, scope: !17)
+++ /dev/null
-; RUN: llvm-as %s -o %t.bc
-; Translation shouldn't crash:
-; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
-; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
-
-; CHECK-LLVM: !DICompileUnit(language: DW_LANG_Fortran95
-; 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))
-; CHECK-LLVM: ![[#BaseT:]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
-; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
-; CHECK-LLVM: ![[#SubRange]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
-
-source_filename = "llvm-link"
-target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
-target triple = "spir64"
-
-!llvm.module.flags = !{!5, !6, !7, !8}
-!llvm.dbg.cu = !{!9}
-
-!0 = !{}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{i32 7, !"PIC Level", i32 2}
-!7 = !{i32 2, !"Debug Info Version", i32 3}
-!8 = !{i32 2, !"Dwarf Version", i32 4}
-!9 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !10, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !0, globals: !0, imports: !22, splitDebugInlining: false, nameTableKind: None)
-!10 = !DIFile(filename: "declare_target_subroutine.F90", directory: "/test")
-!19 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
-!22 = !{!23}
-!23 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !24, entity: !34, file: !10, line: 24)
-!24 = distinct !DISubprogram(name: "declare_target_subroutine", linkageName: "MAIN__", scope: !10, file: !10, line: 23, type: !25, scopeLine: 23, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !9, retainedNodes: !27)
-!25 = !DISubroutineType(types: !26)
-!26 = !{null}
-!27 = !{!30}
-!30 = !DILocalVariable(name: "a", scope: !24, file: !10, line: 28, type: !31)
-!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, elements: !32, 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))
-!32 = !{!33}
-!33 = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
-!34 = !DIModule(scope: !24, name: "iso_fortran_env", isDecl: true)
+++ /dev/null
-;; The test checks, that Fortran dynamic arrays are being correctly represented
-;; by SPIR-V debug information
-;; Unlike 'static' arrays dynamic can have following parameters of
-;; DICompositeType metadata with DW_TAG_array_type tag:
-;; Data Location, Associated, Allocated and Rank which can be represented
-;; by either DIExpression or DIVariable (both local and global).
-;; This test if for expression representation.
-;; FortranDynamicArrayVar.ll is for variable representation.
-
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-kernel-100 -o - | FileCheck %s --check-prefix=CHECK-SPIRV
-; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
-; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
-
-; CHECK-SPIRV-DAG: ExtInstImport [[#Import:]] "NonSemantic.Kernel.DebugInfo.100"
-; CHECK-SPIRV-DAG: String [[#BasicTName:]] "INTEGER*4"
-; CHECK-SPIRV-DAG: TypeInt [[#Int32T:]] 32 0
-; CHECK-SPIRV-DAG: Constant [[#Int32T]] [[#IntConst:]] 32
-; CHECK-SPIRV-DAG: TypeVoid [[#VoidT:]]
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgInfoNone:]] [[#Import]] DebugInfoNone
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#ArrayBasicT:]] [[#Import]] DebugTypeBasic [[#BasicTName]] [[#IntConst]] 4
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLocation:]] [[#Import]] DebugExpression [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprAssociated:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLowerBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprUpperBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprCount:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgSubRangeId:]] [[#Import]] DebugTypeSubrange [[#DbgInfoNone]] [[#DbgExprLowerBound]] [[#DbgExprUpperBound]] [[#DbgExprCount]]
-; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgArrayId:]] [[#Import]] DebugTypeArrayDynamic [[#ArrayBasicT]] [[#DbgExprLocation]] [[#DbgExprAssociated]] [[#DbgInfoNone]] [[#DbgInfoNone]] [[#DbgSubRangeId]]
-
-; CHECK-LLVM: %[[#Array:]] = alloca
-; CHECK-LLVM: call void @llvm.dbg.value(metadata ptr %[[#Array]], metadata ![[#DbgLVar:]]
-; CHECK-LLVM: ![[#DbgLVar]] = !DILocalVariable(name: "pint", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#DbgLVarT:]])
-; CHECK-LLVM: ![[#DbgLVarT]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#DbgArrayT:]], size: 64)
-; CHECK-LLVM: ![[#DbgArrayT]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#DbgArrayBaseT:]], 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))
-; CHECK-LLVM: ![[#DbgArrayBaseT]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
-; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
-; CHECK-LLVM: ![[#SubRange]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
-
-
-; ModuleID = 'reproducer.ll'
-source_filename = "test.f90"
-target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
-target triple = "spir64"
-
-%qnca = type { i32 addrspace(4)*, i64, i64, i64, i64, i64, [1 x { i64, i64, i64 }] }
-
-; Function Attrs: noinline nounwind optnone
-define weak dso_local spir_kernel void @TEST() #0 !dbg !5 {
-newFuncRoot:
- %0 = alloca %qnca, align 8
- call void @llvm.dbg.value(metadata %qnca* %0, metadata !8, metadata !DIExpression()), !dbg !14
- ret void
-}
-
-; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
-declare void @llvm.dbg.value(metadata, metadata, metadata) #1
-
-attributes #0 = { noinline nounwind optnone }
-attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
-
-!llvm.module.flags = !{!0, !1}
-!llvm.dbg.cu = !{!2}
-!spirv.Source = !{!4}
-
-!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = !{i32 2, !"Dwarf Version", i32 4}
-!2 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: "fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
-!3 = !DIFile(filename: "test.f90", directory: "/path/to")
-!4 = !{i32 4, i32 200000}
-!5 = distinct !DISubprogram(name: "test", linkageName: "MAIN__", scope: !3, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
-!6 = !DISubroutineType(types: !7)
-!7 = !{null}
-!8 = !DILocalVariable(name: "pint", scope: !5, file: !3, line: 3, type: !9)
-!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
-!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, elements: !12, 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))
-!11 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
-!12 = !{!13}
-!13 = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref))
-!14 = !DILocation(line: 1, scope: !5)
-
+++ /dev/null
-;; DebugInfo/dwarfdump-dataLocationVar.ll from llvm.org is used as base for this test
-;; The test checks, that Fortran dynamic arrays are being correctly represented
-;; by SPIR-V debug information
-;; Unlike 'static' arrays dynamic can have following parameters of
-;; DICompositeType metadata with DW_TAG_array_type tag:
-;; Data Location, Associated, Allocated and Rank which can be represented
-;; by either DIExpression or DIVariable (both local and global).
-;; This test if for variable representation.
-;; FortranDynamicArrayVar.ll is for expression representation.
-
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-kernel-100 -o - | FileCheck %s --check-prefix=CHECK-SPIRV
-; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-kernel-100
-; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
-; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
-
-;; Major SPIR-V checks are done in FortranDynamicArrayExpr.ll
-; CHECK-SPIRV: ExtInst [[#]] [[#DbgLVarId:]] [[#]] DebugLocalVariable [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] {{$}}
-; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugTypeArrayDynamic [[#]] [[#DbgLVarId]] [[#]] [[#]] [[#]] [[#]]
-
-; CHECK-LLVM: %[[#Ptr:]] = alloca ptr
-; CHECK-LLVM: %[[#Array:]] = alloca [16 x i64]
-; CHECK-LLVM: call void @llvm.dbg.declare(metadata ptr %[[#Array]], metadata ![[#DbgLVarArray:]]
-; CHECK-LLVM: call void @llvm.dbg.declare(metadata ptr %[[#Ptr]], metadata ![[#DbgLVarPtr:]]
-
-; CHECK-LLVM: ![[#DbgLVarPtr:]] = !DILocalVariable(scope: ![[#]], file: ![[#]], type: ![[#DbgPtrT:]], flags: DIFlagArtificial)
-; CHECK-LLVM: ![[#DbgPtrT:]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#DbgBasicT:]], size: 64)
-; CHECK-LLVM: ![[#DbgBasicT]] = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
-; CHECK-LLVM: ![[#DbgLVarArray]] = !DILocalVariable(name: "arr", scope: ![[#]], file: ![[#]], type: ![[#DbgArrayT:]])
-; CHECK-LLVM: ![[#DbgArrayT]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#DbgBasicT]], size: 608, elements: ![[#Elements:]], dataLocation: ![[#DbgLVarPtr]])
-; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]}
-; CHECK-LLVM: ![[#SubRange]] = !DISubrange(count: 19, lowerBound: 2)
-
-; ModuleID = 'fortsubrange.ll'
-source_filename = "fortsubrange.ll"
-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"
-
-define spir_func void @foo() !dbg !5 {
-L.entry:
- %0 = alloca ptr, align 8
- %1 = alloca [16 x i64], align 8
- call void @llvm.dbg.declare(metadata ptr %1, metadata !8, metadata !DIExpression()), !dbg !16
- call void @llvm.dbg.declare(metadata ptr %0, metadata !14, metadata !DIExpression()), !dbg !16
- ret void, !dbg !17
-}
-
-; Function Attrs: nounwind readnone speculatable willreturn
-declare void @llvm.dbg.declare(metadata, metadata, metadata)
-
-; Function Attrs: nounwind readnone speculatable willreturn
-declare void @llvm.dbg.value(metadata, metadata, metadata)
-
-!llvm.module.flags = !{!0, !1}
-!llvm.dbg.cu = !{!2}
-
-!0 = !{i32 2, !"Dwarf Version", i32 4}
-!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !4, imports: !4)
-!3 = !DIFile(filename: "fortsubrange.f90", directory: "/dir")
-!4 = !{}
-!5 = distinct !DISubprogram(name: "main", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
-!6 = !DISubroutineType(cc: DW_CC_program, types: !7)
-!7 = !{null}
-!8 = !DILocalVariable(name: "arr", scope: !9, file: !3, type: !10)
-!9 = !DILexicalBlock(scope: !5, file: !3, line: 1, column: 1)
-!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 32, align: 32, elements: !12, dataLocation: !14)
-!11 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
-!12 = !{!13}
-!13 = !DISubrange(count: 19, lowerBound: 2)
-!14 = distinct !DILocalVariable(scope: !9, file: !3, type: !15, flags: DIFlagArtificial)
-!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32, align: 32)
-!16 = !DILocation(line: 0, scope: !9)
-!17 = !DILocation(line: 6, column: 1, scope: !9)
+++ /dev/null
-; Test checks that DW_LANG_C99, DW_LANG_OpenCL, and all DW_LANG_C_plus_plus_X are mapped to
-; appropriate SourceLanguages in SPIRV when the extended debug info is enabled.
-
-; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C99/' %s | llvm-as - -o %t.bc
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-C99
-
-; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_OpenCL/' %s | llvm-as - -o %t.bc
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-OPENCLC
-
-; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C_plus_plus/' %s | llvm-as - -o %t.bc
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-CPP
-
-; RUN: sed -e 's/INPUT_LANGUAGE/DW_LANG_C_plus_plus_14/' %s | llvm-as - -o %t.bc
-; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-kernel-100 -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-CPP14
-
-; CHECK-C99: DebugCompileUnit [[#]] [[#]] [[#]] 109
-; CHECK-OPENCLC: DebugCompileUnit [[#]] [[#]] [[#]] 3
-; CHECK-CPP: DebugCompileUnit [[#]] [[#]] [[#]] 111
-; CHECK-CPP14: DebugCompileUnit [[#]] [[#]] [[#]] 114
-
-target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
-target triple = "spir64-unknown-unknown"
-
-define dso_local spir_kernel void @func() local_unnamed_addr !dbg !7 !kernel_arg_addr_space !2 !kernel_arg_access_qual !2 !kernel_arg_type !2 !kernel_arg_base_type !2 !kernel_arg_type_qual !2 {
-entry:
- ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5}
-
-!0 = distinct !DICompileUnit(language: INPUT_LANGUAGE, file: !1)
-!1 = !DIFile(filename: "test.cl", directory: "/tmp", checksumkind: CSK_MD5, checksum: "18aa9ce738eaafc7b7b7181c19092815")
-!2 = !{}
-!3 = !{i32 7, !"Dwarf Version", i32 5}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{i32 2, i32 0}
-!7 = distinct !DISubprogram(name: "func", scope: !8, file: !8, line: 1, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
-!8 = !DIFile(filename: "test.cl", directory: "/tmp", checksumkind: CSK_MD5, checksum: "18aa9ce738eaafc7b7b7181c19092815")
"version of SPIR-V debug info format is compatible with the rules "
"regarding non-semantic instruction sets."),
clEnumValN(
- SPIRV::DebugInfoEIS::NonSemantic_Kernel_DebugInfo_100,
- "nonsemantic-kernel-100",
+ SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_200,
+ "nonsemantic-shader-200",
"Emit debug info compliant with the "
- "NonSemantic.Kernel.DebugInfo.100 extended instruction set. This "
+ "NonSemantic.Shader.DebugInfo.200 extended instruction set. This "
"version of SPIR-V debug info format is compatible with the rules "
"regarding non-semantic instruction sets.")));
} else {
Opts.setDebugInfoEIS(DebugEIS);
if (DebugEIS.getValue() ==
- SPIRV::DebugInfoEIS::NonSemantic_Kernel_DebugInfo_100)
+ SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_200)
Opts.setAllowExtraDIExpressionsEnabled(true);
+ if (DebugEIS.getValue() ==
+ SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_200 ||
+ DebugEIS.getValue() ==
+ SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_200)
+ Opts.setAllowedToUseExtension(
+ SPIRV::ExtensionID::SPV_KHR_non_semantic_info);
}
}