Skip to content

release/20.x: [GlobalMerge][PPC] Don't merge globals in llvm.metadata section (#131801) #134052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Apr 2, 2025

Backport 9356091

Requested by: @nikic

@llvmbot
Copy link
Member Author

llvmbot commented Apr 2, 2025

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

@llvmbot
Copy link
Member Author

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-backend-powerpc

Author: None (llvmbot)

Changes

Backport 9356091

Requested by: @nikic


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

2 Files Affected:

  • (modified) llvm/lib/CodeGen/GlobalMerge.cpp (+2-1)
  • (added) llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll (+9)
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 5993fc939a08a..b4650a4851c3c 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -711,7 +711,8 @@ bool GlobalMergeImpl::run(Module &M) {
       continue;
 
     // Ignore all 'special' globals.
-    if (GV.getName().starts_with("llvm.") || GV.getName().starts_with(".llvm."))
+    if (GV.getName().starts_with("llvm.") ||
+        GV.getName().starts_with(".llvm.") || Section == "llvm.metadata")
       continue;
 
     // Ignore all "required" globals:
diff --git a/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll b/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll
new file mode 100644
index 0000000000000..7db092e13afeb
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll
@@ -0,0 +1,9 @@
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
+
+@index = global i32 0, align 4
+@.str = private unnamed_addr constant [1 x i8] zeroinitializer, section "llvm.metadata"
+@.str.1 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata" 
+@llvm.global.annotations = appending global [1 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @index, ptr @.str, ptr @.str.1, i32 1, ptr null }], section "llvm.metadata"
+
+; CHECK-NOT: .set
+; CHECK-NOT: _MergedGlobals

@nikic nikic moved this from Needs Triage to Needs Review in LLVM Release Status Apr 2, 2025
@tstellar
Copy link
Collaborator

Ping @amy-kwan

Copy link
Contributor

@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.

LGTM.

@github-project-automation github-project-automation bot moved this from Needs Review to Needs Merge in LLVM Release Status Apr 16, 2025
…#131801)

The llvm.metadata section is not emitted and has special semantics. We
should not merge globals in it, similarly to how we already skip merging
of `llvm.xyz` globals.

Fixes llvm#131394.

(cherry picked from commit 9356091)
@tstellar tstellar merged commit 78f6719 into llvm:release/20.x Apr 25, 2025
8 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Needs Merge to Done in LLVM Release Status Apr 25, 2025
Copy link

@nikic (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants