[llvm] [NFC][ModuleUtils] Move externalize() from module splitting utilities (PR #221181)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 06:05:20 PDT 2026


================
@@ -381,6 +381,18 @@ std::string llvm::getUniqueModuleId(Module *M) {
   return ("." + Str).str();
 }
 
+void llvm::externalizeGlobal(GlobalValue &GV) {
----------------
mmjjpp wrote:

That's a fair point — it only touches the GV itself. I went a slightly different way though: the __llvmsplit_unnamed naming part is splitting-specific policy that I'd rather keep out of core IR, so instead of a GlobalValue member I created Transforms/Utils/SplitModuleCommon.{h,cpp} as a shared home for module splitting utilities. It exposes externalizeGlobal() (linkage promotion + naming) and nameUnnamedGlobalValue() (naming alone). The latter also lets SplitModule.cpp's recordGVSet (PreserveLocals path) reuse the naming logic instead of its own copy. If more shared pieces emerge, they have a natural landing spot there.

The latest commit implements this — let me know if you're okay with this approach. If it doesn't feel right, I'm happy to revert it and discuss a better alternative.

https://github.com/llvm/llvm-project/pull/221181


More information about the llvm-commits mailing list