Skip to content

Commit 5b563a0

Browse files
Andrew Savonichevvmaksimo
authored andcommitted
Support missing DWARF opcodes (#679)
Experimental support of extra DWARF operations As this functionality is not documented by any formal SPIR-V extension or SPIR-V extended instruction set specification, it is disabled by default and in order to enable generation of extra debug information, user needs to pass `spirv-allow-extra-diexpressions` command line option to the translator. Signed-off-by: Andrew Savonichev <andrew.savonichev@intel.com>
1 parent 7308f85 commit 5b563a0

File tree

7 files changed

+650
-23
lines changed

7 files changed

+650
-23
lines changed

llvm-spirv/include/LLVMSPIRVOpts.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ class TranslatorOpts {
148148
SPIRVAllowUnknownIntrinsics = AllowUnknownIntrinsics;
149149
}
150150

151+
bool allowExtraDIExpressions() const noexcept {
152+
return AllowExtraDIExpressions;
153+
}
154+
155+
void setAllowExtraDIExpressionsEnabled(bool Allow) noexcept {
156+
AllowExtraDIExpressions = Allow;
157+
}
158+
151159
DebugInfoEIS getDebugInfoEIS() const { return DebugInfoVersion; }
152160

153161
void setDebugInfoEIS(DebugInfoEIS EIS) { DebugInfoVersion = EIS; }
@@ -179,6 +187,10 @@ class TranslatorOpts {
179187
// SPIR-V
180188
bool SPIRVAllowUnknownIntrinsics = false;
181189

190+
// Enable support for extra DIExpression opcodes not listed in the SPIR-V
191+
// DebugInfo specification.
192+
bool AllowExtraDIExpressions = false;
193+
182194
DebugInfoEIS DebugInfoVersion = DebugInfoEIS::OpenCL_DebugInfo_100;
183195
};
184196

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,14 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgExpression(const DIExpression *Expr) {
959959
for (unsigned I = 0, N = Expr->getNumElements(); I < N; ++I) {
960960
using namespace SPIRVDebug::Operand::Operation;
961961
auto DWARFOpCode = static_cast<dwarf::LocationAtom>(Expr->getElement(I));
962+
962963
SPIRVDebug::ExpressionOpCode OC =
963964
SPIRV::DbgExpressionOpCodeMap::map(DWARFOpCode);
964-
assert(OpCountMap.find(OC) != OpCountMap.end() &&
965-
"unhandled opcode found in DIExpression");
965+
if (OpCountMap.find(OC) == OpCountMap.end())
966+
report_fatal_error("unknown opcode found in DIExpression");
967+
if (OC > SPIRVDebug::Fragment && !BM->allowExtraDIExpressions())
968+
report_fatal_error("unsupported opcode found in DIExpression");
969+
966970
unsigned OpCount = OpCountMap[OC];
967971
SPIRVWordVec Op(OpCount);
968972
Op[OpCodeIdx] = OC;

0 commit comments

Comments
 (0)