[llvm] [DebugInfo] Add DILayerLoc/DILayerLocList and DILocation irlayers operand (PR #215666)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 05:53:01 PDT 2026
================
@@ -220,6 +275,40 @@ struct ScopeLocationsMatcher {
}
};
+// Returns a uniqued DILayerLocList holding the intersection of LocA's and
+// LocB's layer sets, or null if either has no layers or they share none.
+// Entries keep LocA's relative order: LLVM assigns no meaning to layer order,
+// but it is part of a list's identity and visible to consumers, so preserve
+// rather than sort.
+static Metadata *mergeIRLayers(LLVMContext &C, const DILocation *LocA,
+ const DILocation *LocB) {
+ DILayerLocList *LA = LocA->getIRLayers();
+ DILayerLocList *LB = LocB->getIRLayers();
+ if (!LA || !LB)
+ return nullptr;
+ // Entries match on their fields rather than by pointer: DILayerLocs are
+ // uniqued, but `distinct` ones are legal and must not look disjoint. Keying
+ // on the fields also keeps the intersection linear in the two list lengths.
+ using LayerKey = std::tuple<Metadata *, Metadata *, unsigned, unsigned>;
+ auto keyOf = [](const DILayerLoc *L) {
+ return LayerKey(L->getRawKind(), L->getRawFile(), L->getLine(),
+ L->getColumn());
+ };
+ SmallDenseSet<LayerKey, 2> BLayers;
+ for (unsigned I = 0, E = LB->getNumLayers(); I != E; ++I)
----------------
SLTozer wrote:
For this and the loop below, may be more intuitive to loop over `layers()`?
https://github.com/llvm/llvm-project/pull/215666
More information about the llvm-commits
mailing list