https://github.com/mingmingl-llvm updated 
https://github.com/llvm/llvm-project/pull/162349

>From c56b792ba0dca69ef75fb42b0c3bb8e3b429bbec Mon Sep 17 00:00:00 2001
From: mingmingl <[email protected]>
Date: Tue, 7 Oct 2025 12:24:30 -0700
Subject: [PATCH 1/2] Get rid of section prefix validation in codegen.

---
 llvm/lib/CodeGen/StaticDataAnnotator.cpp | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/llvm/lib/CodeGen/StaticDataAnnotator.cpp 
b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
index 9b737751c4a98..eac2012017087 100644
--- a/llvm/lib/CodeGen/StaticDataAnnotator.cpp
+++ b/llvm/lib/CodeGen/StaticDataAnnotator.cpp
@@ -78,19 +78,8 @@ bool StaticDataAnnotator::runOnModule(Module &M) {
     if (!llvm::memprof::IsAnnotationOK(GV))
       continue;
 
-    // The implementation below assumes prior passes don't set section 
prefixes,
-    // and specifically do 'assign' rather than 'update'. So report error if a
-    // section prefix is already set.
-    if (auto maybeSectionPrefix = GV.getSectionPrefix();
-        maybeSectionPrefix && !maybeSectionPrefix->empty())
-      llvm::report_fatal_error("Global variable " + GV.getName() +
-                               " already has a section prefix " +
-                               *maybeSectionPrefix);
-
     StringRef SectionPrefix = SDPI->getConstantSectionPrefix(&GV, PSI);
-    if (SectionPrefix.empty())
-      continue;
-
+    // setSectionPrefix returns true if the section prefix is updated.
     Changed |= GV.setSectionPrefix(SectionPrefix);
   }
 

>From 90ac67d80b318f49c2e037b48cee10da0137d9cf Mon Sep 17 00:00:00 2001
From: mingmingl <[email protected]>
Date: Wed, 8 Oct 2025 17:18:54 -0700
Subject: [PATCH 2/2] test coverage

---
 .../CodeGen/X86/global-variable-partition-with-dap.ll  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll 
b/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
index 7214273ff6d9c..f3950b75a969f 100644
--- a/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
+++ b/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
@@ -1,15 +1,15 @@
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-;; A minimal test case. llc will crash if global variables already has a 
section
-;; prefix. Subsequent PRs will expand on this test case to test the hotness
+;; A minimal test case. Subsequent PRs will expand on this test case
+;; (e.g., with more functions, variables and profiles) and test the hotness
 ;; reconcillation implementation.
-; RUN: not llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
 ; RUN:     -partition-static-data-sections=true \
 ; RUN:     -data-sections=true  -unique-section-names=false \
-; RUN:     %s -o - 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN:     %s -o - 2>&1 | FileCheck %s --check-prefix=IR
 
-; ERR: Global variable hot_bss already has a section prefix hot
+; IR: .section .bss.hot.,"aw"
 
 @hot_bss = internal global i32 0, !section_prefix !17
 

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to