Skip to content

release/22.x: [PowerPC] Only set QualName symbol on first section switch (#179253)#179631

Merged
c-rhodes merged 1 commit intollvm:release/22.xfrom
llvmbot:issue179253
Feb 20, 2026
Merged

release/22.x: [PowerPC] Only set QualName symbol on first section switch (#179253)#179631
c-rhodes merged 1 commit intollvm:release/22.xfrom
llvmbot:issue179253

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 4, 2026

Backport 90c632a

Requested by: @nikic

@llvmbot
Copy link
Member Author

llvmbot commented Feb 4, 2026

@amy-kwan What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Feb 4, 2026

@llvm/pr-subscribers-llvm-mc

@llvm/pr-subscribers-backend-powerpc

Author: None (llvmbot)

Changes

Backport 90c632a

Requested by: @nikic


Full diff: https://github.com/llvm/llvm-project/pull/179631.diff

2 Files Affected:

  • (modified) llvm/lib/MC/MCXCOFFStreamer.cpp (+6-2)
  • (added) llvm/test/CodeGen/PowerPC/aix-debug-aranges.ll (+28)
diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp
index 4bf14c11068cb..b459b26045ae7 100644
--- a/llvm/lib/MC/MCXCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -45,8 +45,12 @@ void MCXCOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
   // sections because we don't have other cases that hit this problem yet.
   // if (IsDwarfSec || CsectProp->MappingClass == XCOFF::XMC_PR)
   //   QualName->setFragment(F);
-  if (Sec->isDwarfSect() || Sec->getMappingClass() == XCOFF::XMC_PR)
-    Sec->getQualNameSymbol()->setFragment(CurFrag);
+  if (Sec->isDwarfSect() || Sec->getMappingClass() == XCOFF::XMC_PR) {
+    MCSymbol *QualNameSymbol = Sec->getQualNameSymbol();
+    // Only set the fragment the first time we're switching to the section.
+    if (!QualNameSymbol->isInSection())
+      QualNameSymbol->setFragment(CurFrag);
+  }
 }
 
 bool MCXCOFFStreamer::emitSymbolAttribute(MCSymbol *Sym,
diff --git a/llvm/test/CodeGen/PowerPC/aix-debug-aranges.ll b/llvm/test/CodeGen/PowerPC/aix-debug-aranges.ll
new file mode 100644
index 0000000000000..7b850b6f2a2d0
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/aix-debug-aranges.ll
@@ -0,0 +1,28 @@
+; RUN: llc -filetype=obj -function-sections -generate-arange-section < %s | \
+; RUN: llvm-objdump -dr - | FileCheck %s
+
+; Make sure that enabling debug_arange does not corrupt branches.
+
+target triple = "powerpc64-ibm-aix"
+
+define i64 @fn1() {
+; CHECK-LABEL: <.fn1>:
+; CHECK: bl {{.*}} <.fn2>
+; CHECK-NEXT: R_RBR .fn2
+  %1 = call i64 @fn2()
+  ret i64 %1
+}
+
+define i64 @fn2() !dbg !4 {
+  ret i64 0
+}
+
+!llvm.module.flags = !{!0}
+!llvm.dbg.cu = !{!1}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !2, producer: "clang LLVM (rustc version 1.95.0-dev)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !3, splitDebugInlining: false, nameTableKind: None)
+!2 = !DIFile(filename: "foo", directory: "")
+!3 = !{}
+!4 = distinct !DISubprogram(name: "fn2", file: !2, line: 277, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !1, templateParams: !3, retainedNodes: !3)
+!5 = !DISubroutineType(types: !3)

@c-rhodes c-rhodes moved this from Needs Triage to Needs Review in LLVM Release Status Feb 4, 2026
@nikic
Copy link
Contributor

nikic commented Feb 9, 2026

@amy-kwan Ping for backport review.

rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Feb 11, 2026
Update to LLVM 22.1.0-rc3

Update to LLVM 22.1.0-rc3, plus a cherry-pick of llvm/llvm-project#179631 which is still pending backport upstream.

Fixes #151926.
Fixes #151832.
Fixes #151818.
Fixes #151807.
Fixes [#t-compiler/help > Inlining causing function to get replace with TRAP](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Inlining.20causing.20function.20to.20get.20replace.20with.20TRAP/with/568824178).

Should also address #131745, but we should verify that separately.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Feb 16, 2026
Update to LLVM 22.1.0-rc3

Update to LLVM 22.1.0-rc3, plus a cherry-pick of llvm/llvm-project#179631 which is still pending backport upstream.

Fixes rust-lang/rust#151926.
Fixes rust-lang/rust#151832.
Fixes rust-lang/rust#151818.
Fixes rust-lang/rust#151807.
Fixes [#t-compiler/help > Inlining causing function to get replace with TRAP](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Inlining.20causing.20function.20to.20get.20replace.20with.20TRAP/with/568824178).

Should also address rust-lang/rust#131745, but we should verify that separately.
@nikic
Copy link
Contributor

nikic commented Feb 16, 2026

Ping :)

Copy link
Member

@amy-kwan amy-kwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in this. LGTM.

@github-project-automation github-project-automation bot moved this from Needs Review to Needs Merge in LLVM Release Status Feb 19, 2026
We were setting it every time when switching to the section. This caused
problems when the debug_aranges emission performed a switch at the end
of the section, resulting in symbols incorrectly pointing to the end
instead of the start of the function.

(cherry picked from commit 90c632a)
@c-rhodes c-rhodes merged commit 0cb9602 into llvm:release/22.x Feb 20, 2026
2 of 3 checks passed
@github-project-automation github-project-automation bot moved this from Needs Merge to Done in LLVM Release Status Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:PowerPC llvm:mc Machine (object) code

Projects

Development

Successfully merging this pull request may close these issues.

4 participants