[clang] [llvm] Disentangle DISubprogram ODR type method uniquing from metadata uniquing (PR #217042)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 02:02:03 PDT 2026
================
@@ -0,0 +1,40 @@
+//===- llvm/IR/DebugInfoODRUniquer.cpp - Debug Information Builder --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines a class used to merge debug info for ODR types.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/DebugInfoODRUniquer.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+
+using namespace llvm;
+
+DISubprogram *
+DebugInfoODRUniquer::getODRSubprogramDecl(Metadata *Scope,
+ StringRef LinkageName, Metadata *Type,
+ Metadata *TemplateParams) {
+ // Only methods, which have a type scope, are eligable for ODR uniquing.
+ auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
+ if (!CT || !CT->getRawIdentifier())
+ return nullptr;
+
+ auto R =
+ FnDecls.find_as(DISubprogramODRKey(CT->getIdentifier(), LinkageName));
+ if (R == FnDecls.end())
+ return nullptr;
+
+ assert(!(*R)->isDefinition() && "definition unexpectedly ODR-uniqued");
+ return *R;
+}
+
+void DebugInfoODRUniquer::addSubprogramDecl(DISubprogram *SP) {
+ assert(!SP->isDefinition() &&
+ "only expect declarations DISubprogram ODR uniquing");
+ FnDecls.insert(SP);
----------------
OCHyams wrote:
Oh yeah, makes sense, done
https://github.com/llvm/llvm-project/pull/217042
More information about the llvm-commits
mailing list