-
Notifications
You must be signed in to change notification settings - Fork 254
Add support for debug macro information (DW_MACINFO_define/undef) #3562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implement bidirectional translation of LLVM DIMacro to SPIR-V DebugMacroDef and DebugMacroUndef instructions. LLVM to SPIR-V: - Add transDbgMacros() to process all macro definitions and undefs - Add transDbgMacroDefine() to translate DW_MACINFO_define to DebugMacroDef - Add transDbgMacroUndef() to translate DW_MACINFO_undef to DebugMacroUndef - DW_MACINFO_define are processed first, so they are available for DW_MACINFO_undef cases. SPIR-V to LLVM: - Add transMacroDef() to translate DebugMacroDef back to DIMacro - Add transMacroUndef() to translate DebugMacroUndef back to DIMacro - Add getOrCreateMacroFile() to manage DIMacroFile creation - Handle edge case where LLVM IR allows undefining macros that were never defined (DebugMacroUndef with DebugInfoNone reference)
|
Re-opened PR after merging required changes in LLVM (llvm/llvm-project#179931). |
|
Out-of-tree build and clang-tidy fail because they are using an older version of LLVM which doesn' have the required changes. |
|
Will take a look early next week. |
| ; Test round-trip translation of debug macro information: | ||
| ; LLVM IR -> SPIR-V -> LLVM IR | ||
|
|
||
| ; RUN: llvm-spirv --spirv-debug-info-version=nonsemantic-shader-100 %s -o %t.spv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement bidirectional translation of LLVM DIMacro to SPIR-V DebugMacroDef and DebugMacroUndef instructions.
Note, that the spec links in the PR description are leading to OpenCL.DebugInfo.100 instruction set, while:
a. tests are covering nonsemantic debug info;
b. code is also build for nonsemantic, see few Literal parameters of the instructions in the referenced OpenCL spec, while in the implementation (and nonsemantic variant) there operands are Ids.
I'd suggest to test and implement all 3 debug information types: OpenCL, nonsemantic.100 and nonsemantic.200. The later 2 are identical for Macro handling. OpenCL is a bit different, but not that drastically: see the following lines here and there which transforms literals to constants:
if (isNonSemanticDebugInfo())
transformToConstant(Ops, {ScopeLineIdx});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, will do.
| Ops.resize(OperandCount); | ||
| Ops[SourceIdx] = FileName->getId(); | ||
| Ops[LineIdx] = | ||
| SPIRVWriter->transValue(getUInt(M, Macro->getLine()), nullptr)->getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm looking correctly at the spec, Line is a literal number, not an <id>.
| using namespace SPIRVDebug::Operand::MacroUndef; | ||
| Ops.resize(OperandCount); | ||
| Ops[SourceIdx] = FileName->getId(); | ||
| Ops[LineIdx] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same than above.
| SPIRVId MacroDefId = getDebugInfoNoneId(); | ||
|
|
||
| // transDbgMacroDefine is processed first so MacroDefMap is already populated | ||
| // at this point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // at this point | |
| // at this point. |
Implement bidirectional translation of LLVM DIMacro to SPIR-V DebugMacroDef and DebugMacroUndef instructions.
LLVM to SPIR-V:
SPIR-V to LLVM: