[llvm] [NFCI][Globals]For GlobalObjects, add updateSectionPrefix and change setSectionPrefix to handle empty strings (PR #158460)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 07:41:09 PDT 2025
================
@@ -289,11 +289,28 @@ void GlobalObject::setSection(StringRef S) {
}
void GlobalObject::setSectionPrefix(StringRef Prefix) {
+ if (Prefix.empty()) {
+ setMetadata(LLVMContext::MD_section_prefix, nullptr);
+ return;
+ }
MDBuilder MDB(getContext());
setMetadata(LLVMContext::MD_section_prefix,
MDB.createGlobalObjectSectionPrefix(Prefix));
}
+bool GlobalObject::updateSectionPrefix(StringRef Prefix) {
+ auto MD = getMetadata(LLVMContext::MD_section_prefix);
----------------
teresajohnson wrote:
Use getSectionPrefix instead? It does some assertion checking that could be useful.
Also, does it make sense to just make this the default behavior of setSectionPrefix?
https://github.com/llvm/llvm-project/pull/158460
More information about the llvm-commits
mailing list