From 7bebb7e83ef7aee32cd7af9b75aa0ab7ceccac1f Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Mon, 6 Jan 2025 14:29:37 -0800 Subject: [PATCH 1/2] [nfc][thinlto] remove unused return from `renameModuleForThinLTO` Same goes for `FunctionImportGlobalProcessing::run`. --- .../llvm/Transforms/Utils/FunctionImportUtils.h | 4 ++-- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 3 +-- llvm/lib/Transforms/IPO/FunctionImport.cpp | 12 ++++-------- llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | 7 +++---- llvm/tools/llvm-link/llvm-link.cpp | 5 ++--- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h index 749b7b2bb5d86..18cd923d5601d 100644 --- a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h +++ b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h @@ -120,12 +120,12 @@ class FunctionImportGlobalProcessing { #endif } - bool run(); + void run(); }; /// Perform in-place global value handling on the given Module for /// exported local functions renamed and promoted for ThinLTO. -bool renameModuleForThinLTO( +void renameModuleForThinLTO( Module &M, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations, SetVector *GlobalsToImport = nullptr); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 4522f4adcebe6..189f2876b61c0 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -160,8 +160,7 @@ generateModuleMap(std::vector> &Modules) { static void promoteModule(Module &TheModule, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations) { - if (renameModuleForThinLTO(TheModule, Index, ClearDSOLocalOnDeclarations)) - report_fatal_error("renameModuleForThinLTO failed"); + renameModuleForThinLTO(TheModule, Index, ClearDSOLocalOnDeclarations); } namespace { diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index fde43bb354e83..c4ef819466df9 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1950,9 +1950,8 @@ Expected FunctionImporter::importFunctions( SrcModule->setPartialSampleProfileRatio(Index); // Link in the specified functions. - if (renameModuleForThinLTO(*SrcModule, Index, ClearDSOLocalOnDeclarations, - &GlobalsToImport)) - return true; + renameModuleForThinLTO(*SrcModule, Index, ClearDSOLocalOnDeclarations, + &GlobalsToImport); if (PrintImports) { for (const auto *GV : GlobalsToImport) @@ -2026,11 +2025,8 @@ static bool doImportingForModuleForTest( // Next we need to promote to global scope and rename any local values that // are potentially exported to other modules. - if (renameModuleForThinLTO(M, *Index, /*ClearDSOLocalOnDeclarations=*/false, - /*GlobalsToImport=*/nullptr)) { - errs() << "Error renaming module\n"; - return true; - } + renameModuleForThinLTO(M, *Index, /*ClearDSOLocalOnDeclarations=*/false, + /*GlobalsToImport=*/nullptr); // Perform the import now. auto ModuleLoader = [&M](StringRef Identifier) { diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp index 766c7501550da..6f0c349320bc8 100644 --- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp +++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp @@ -331,15 +331,14 @@ void FunctionImportGlobalProcessing::processGlobalsForThinLTO() { } } -bool FunctionImportGlobalProcessing::run() { +void FunctionImportGlobalProcessing::run() { processGlobalsForThinLTO(); - return false; } -bool llvm::renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, +void llvm::renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations, SetVector *GlobalsToImport) { FunctionImportGlobalProcessing ThinLTOProcessing(M, Index, GlobalsToImport, ClearDSOLocalOnDeclarations); - return ThinLTOProcessing.run(); + ThinLTOProcessing.run(); } diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index 34bb6ce30b766..2adcbb8840a88 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -449,9 +449,8 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L, } // Promotion - if (renameModuleForThinLTO(*M, *Index, - /*ClearDSOLocalOnDeclarations=*/false)) - return true; + renameModuleForThinLTO(*M, *Index, + /*ClearDSOLocalOnDeclarations=*/false); } if (Verbose) From 32758969f0485a5e300df2ffc586f3c020531ba9 Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Mon, 6 Jan 2025 14:31:36 -0800 Subject: [PATCH 2/2] clang-format --- llvm/lib/Transforms/IPO/FunctionImport.cpp | 4 ++-- llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | 4 +--- llvm/tools/llvm-link/llvm-link.cpp | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index c4ef819466df9..c3d0a1a3a046e 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1951,7 +1951,7 @@ Expected FunctionImporter::importFunctions( // Link in the specified functions. renameModuleForThinLTO(*SrcModule, Index, ClearDSOLocalOnDeclarations, - &GlobalsToImport); + &GlobalsToImport); if (PrintImports) { for (const auto *GV : GlobalsToImport) @@ -2026,7 +2026,7 @@ static bool doImportingForModuleForTest( // Next we need to promote to global scope and rename any local values that // are potentially exported to other modules. renameModuleForThinLTO(M, *Index, /*ClearDSOLocalOnDeclarations=*/false, - /*GlobalsToImport=*/nullptr); + /*GlobalsToImport=*/nullptr); // Perform the import now. auto ModuleLoader = [&M](StringRef Identifier) { diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp index 6f0c349320bc8..ae1af943bc11c 100644 --- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp +++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp @@ -331,9 +331,7 @@ void FunctionImportGlobalProcessing::processGlobalsForThinLTO() { } } -void FunctionImportGlobalProcessing::run() { - processGlobalsForThinLTO(); -} +void FunctionImportGlobalProcessing::run() { processGlobalsForThinLTO(); } void llvm::renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations, diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index 2adcbb8840a88..0f4a4d57427a5 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -450,7 +450,7 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L, // Promotion renameModuleForThinLTO(*M, *Index, - /*ClearDSOLocalOnDeclarations=*/false); + /*ClearDSOLocalOnDeclarations=*/false); } if (Verbose)