[llvm] [llvm-debuginfo-analyzer] Add support for LLVM IR format. (PR #135440)

Javier Lopez-Gomez via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 3 08:01:22 PDT 2025


================
@@ -555,10 +555,14 @@ void LVElement::printLinkageName(raw_ostream &OS, bool Full,
 void LVElement::printLinkageName(raw_ostream &OS, bool Full, LVElement *Parent,
                                  LVScope *Scope) const {
   if (options().getPrintFormatting() && options().getAttributeLinkage()) {
-    LVSectionIndex SectionIndex = getReader().getSectionIndex(Scope);
-    std::string Text = (Twine(" 0x") + Twine::utohexstr(SectionIndex) +
-                        Twine(" '") + Twine(getLinkageName()) + Twine("'"))
-                           .str();
+    // Include the section index only if '--attribute=offset', as the
+    // index can be different depending on the specific reader.
+    std::string Section;
+    if (options().getAttributeOffset()) {
+      LVSectionIndex SectionIndex = getReader().getSectionIndex(Scope);
+      Section = (Twine(" 0x" + Twine::utohexstr(SectionIndex) + " ")).str();
+    }
+    std::string Text = (Twine(Section + "'" + getLinkageName() + "'")).str();
----------------
jalopezg-git wrote:

This possibly doesn't do what was intended.  Given that `Section` is a `std::string`, this will call `operator+()` to construct another `std::string`, etc.

The previous state (before this PR) can be used as reference to fix this issue.

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


More information about the llvm-commits mailing list