Skip to content

Commit 9356091

Browse files
authored
[GlobalMerge][PPC] Don't merge globals in llvm.metadata section (llvm#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.
1 parent 10c6ebc commit 9356091

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/CodeGen/GlobalMerge.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ bool GlobalMergeImpl::run(Module &M) {
713713
continue;
714714

715715
// Ignore all 'special' globals.
716-
if (GV.getName().starts_with("llvm.") || GV.getName().starts_with(".llvm."))
716+
if (GV.getName().starts_with("llvm.") ||
717+
GV.getName().starts_with(".llvm.") || Section == "llvm.metadata")
717718
continue;
718719

719720
// Ignore all "required" globals:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2+
3+
@index = global i32 0, align 4
4+
@.str = private unnamed_addr constant [1 x i8] zeroinitializer, section "llvm.metadata"
5+
@.str.1 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata"
6+
@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"
7+
8+
; CHECK-NOT: .set
9+
; CHECK-NOT: _MergedGlobals

0 commit comments

Comments
 (0)