[llvm] [DebugInfo] Add DILayerLoc/DILayerLocList and DILocation irlayers operand (PR #215666)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 03:07:26 PDT 2026
================
@@ -2945,11 +3062,32 @@ class DILocation : public MDNode {
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawInlinedAt() const {
- if (getNumOperands() == 2)
+ // Layout: [scope, (inlinedAt?), (irlayers?)]. irlayers, when present, is
+ // always the last operand; discount it before the inlinedAt count trick.
+ unsigned NonLayerOps = getNumOperands() - (HasIRLayers ? 1 : 0);
+ if (NonLayerOps == 2)
return getOperand(1);
return nullptr;
}
+ /// The optional intermediate-IR layer list (\a DILayerLocList), or null.
+ /// Raw form: returns the operand without casting, so it is safe to call
+ /// before forward-ref resolution (the operand may still be a placeholder).
+ Metadata *getRawIRLayers() const {
+ return HasIRLayers ? getOperand(getNumOperands() - 1) : nullptr;
----------------
nikic wrote:
This fails to build with GCC:
```
FAILED: lib/IR/CMakeFiles/LLVMCore.dir/Attributes.cpp.o
CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /usr/bin/c++ -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/llvm-project-build-stage1/lib/IR -I/var/llvm-compile-time-tracker/llvm-project/llvm/lib/IR -I/tmp/llvm-project-build-stage1/include -I/var/llvm-compile-time-tracker/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT lib/IR/CMakeFiles/LLVMCore.dir/Attributes.cpp.o -MF lib/IR/CMakeFiles/LLVMCore.dir/Attributes.cpp.o.d -o lib/IR/CMakeFiles/LLVMCore.dir/Attributes.cpp.o -c /var/llvm-compile-time-tracker/llvm-project/llvm/lib/IR/Attributes.cpp
In file included from /var/llvm-compile-time-tracker/llvm-project/llvm/lib/IR/LLVMContextImpl.h:32,
from /var/llvm-compile-time-tracker/llvm-project/llvm/lib/IR/Attributes.cpp:17:
/var/llvm-compile-time-tracker/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h: In member function ‘llvm::Metadata* llvm::DILocation::getRawIRLayers() const’:
/var/llvm-compile-time-tracker/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h:3078:24: error: operands to ‘?:’ have different types ‘const llvm::MDOperand’ and ‘std::nullptr_t’
3078 | return HasIRLayers ? getOperand(getNumOperands() - 1) : nullptr;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
https://github.com/llvm/llvm-project/pull/215666
More information about the llvm-commits
mailing list