[llvm] 9356091 - [GlobalMerge][PPC] Don't merge globals in llvm.metadata section (#131801)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 2 01:40:57 PDT 2025
Author: Nikita Popov
Date: 2025-04-02T10:40:53+02:00
New Revision: 9356091a98c24718572f99b51553838ed664b67a
URL: https://github.com/llvm/llvm-project/commit/9356091a98c24718572f99b51553838ed664b67a
DIFF: https://github.com/llvm/llvm-project/commit/9356091a98c24718572f99b51553838ed664b67a.diff
LOG: [GlobalMerge][PPC] Don't merge globals in llvm.metadata section (#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 https://github.com/llvm/llvm-project/issues/131394.
Added:
llvm/test/CodeGen/PowerPC/global-merge-llvm-metadata.ll
Modified:
llvm/lib/CodeGen/GlobalMerge.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index d0918acbe48fa..e58d7e344c28b 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -713,7 +713,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
+
+ at index = global i32 0, align 4
+ at .str = private unnamed_addr constant [1 x i8] zeroinitializer, section "llvm.metadata"
+ at .str.1 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata"
+ at 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
More information about the llvm-commits
mailing list