[llvm] [DebugInfo] Add DILayerLoc/DILayerLocList and DILocation irlayers operand (PR #215666)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 12:56:49 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;
----------------
ayermolo wrote:

@nikic All good on your end? Anything else I need to address?

https://github.com/llvm/llvm-project/pull/215666


More information about the llvm-commits mailing list