[lld] [llvm] [NFCI][LTO][lld] Optimize away symbol copies within LTO global resolution in ELF (PR #106193)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 09:37:30 PDT 2024


================
@@ -626,7 +636,12 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
     assert(ResI != ResE);
     SymbolResolution Res = *ResI++;
 
-    auto &GlobalRes = (*GlobalResolutions)[Sym.getName()];
+    StringRef SymbolName = Sym.getName();
+    // Keep copies of symbols if the client of LTO says so.
+    if (GlobalResolutionSymbolSaver && !GlobalResolutions->contains(SymbolName))
+      SymbolName = GlobalResolutionSymbolSaver->save(SymbolName);
+
+    auto &GlobalRes = (*GlobalResolutions)[SymbolName];
----------------
minglotus-6 wrote:

I added a helper method `LTO::releaseGlobalResolutionsMemory` which releases the memory used by GlobalResolutions together. I'm not sure if having a wrapper class has the correct ROI for code simplicity here as reader also need to parse the added logic of wrapper class.

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


More information about the llvm-commits mailing list