[llvm] [ElimAvailExtern] Add an option to allow to convert global variables in a specified address space to local (PR #144287)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 10:08:27 PDT 2025
================
@@ -88,9 +94,32 @@ static void convertToLocalCopy(Module &M, Function &F) {
++NumConversions;
}
+static void convertToLocalCopy(Module &M, GlobalValue &GV) {
+ assert(GV.hasAvailableExternallyLinkage());
+ std::string OrigName = GV.getName().str();
+ std::string NewName = OrigName + ".__uniq" + getUniqueModuleId(&M);
+ GV.setName(NewName);
+ GV.setLinkage(GlobalValue::InternalLinkage);
+ ++NumConversions;
+}
+
static bool eliminateAvailableExternally(Module &M, bool Convert) {
bool Changed = false;
+ // Convert global variables in specified address space before changing it to
+ // external linkage below.
+ if (ConvertGlobalVariableInAddrSpace.getNumOccurrences()) {
----------------
mtrofin wrote:
Can't see why that would be a problem.
https://github.com/llvm/llvm-project/pull/144287
More information about the llvm-commits
mailing list