[llvm-branch-commits] [llvm] [NFCI][StaticDataLayout] Get rid of section prefix validation in codegen (PR #162349)
Mingming Liu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 7 12:30:36 PDT 2025
https://github.com/mingmingl-llvm created https://github.com/llvm/llvm-project/pull/162349
The section prefix validation was initially added when global variable's section prefix is only added in the codegen pass.
Now the optimizer pass MemProfUse can annotate data section prefix by making use of data access profiles, so we can remove the validation. Also calls `setSectionPrefix` which returns whether section prefix is updated.
>From c56b792ba0dca69ef75fb42b0c3bb8e3b429bbec Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Tue, 7 Oct 2025 12:24:30 -0700
Subject: [PATCH] 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);
}
More information about the llvm-branch-commits
mailing list