From 2e6ac54cf48aa04f7b05c382c33135b16d3f01ea Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Fri, 15 Apr 2022 16:03:48 -0700 Subject: [PATCH] [LegacyPM] Remove ThinLTO/LTO pipelines Using the legacy PM for the optimization pipeline was deprecated in 13.0.0. Following recent changes to remove non-core features of the legacy PM/optimization pipeline, remove the (Thin)LTO pipelines. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D123882 --- .../include/llvm-c/Transforms/PassManagerBuilder.h | 6 -- .../llvm/Transforms/IPO/PassManagerBuilder.h | 2 - llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 89 ---------------------- llvm/tools/bugpoint/bugpoint.cpp | 10 --- 4 files changed, 107 deletions(-) diff --git a/llvm/include/llvm-c/Transforms/PassManagerBuilder.h b/llvm/include/llvm-c/Transforms/PassManagerBuilder.h index 6e13e18..3ba7544 100644 --- a/llvm/include/llvm-c/Transforms/PassManagerBuilder.h +++ b/llvm/include/llvm-c/Transforms/PassManagerBuilder.h @@ -72,12 +72,6 @@ void LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM); -/** See llvm::PassManagerBuilder::populateLTOPassManager. */ -void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, - LLVMPassManagerRef PM, - LLVMBool Internalize, - LLVMBool RunInliner); - /** * @} */ diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index d4aa7ac..2676f27 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -224,8 +224,6 @@ public: /// populateModulePassManager - This sets up the primary pass manager. void populateModulePassManager(legacy::PassManagerBase &MPM); - void populateLTOPassManager(legacy::PassManagerBase &PM); - void populateThinLTOPassManager(legacy::PassManagerBase &PM); }; /// Registers a function for adding a standard set of passes. This should be diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 7267145..4f85700 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -1092,80 +1092,6 @@ void PassManagerBuilder::addLateLTOOptimizationPasses( PM.add(createMergeFunctionsPass()); } -void PassManagerBuilder::populateThinLTOPassManager( - legacy::PassManagerBase &PM) { - PerformThinLTO = true; - if (LibraryInfo) - PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); - - if (VerifyInput) - PM.add(createVerifierPass()); - - if (ImportSummary) { - // This pass imports type identifier resolutions for whole-program - // devirtualization and CFI. It must run early because other passes may - // disturb the specific instruction patterns that these passes look for, - // creating dependencies on resolutions that may not appear in the summary. - // - // For example, GVN may transform the pattern assume(type.test) appearing in - // two basic blocks into assume(phi(type.test, type.test)), which would - // transform a dependency on a WPD resolution into a dependency on a type - // identifier resolution for CFI. - // - // Also, WPD has access to more precise information than ICP and can - // devirtualize more effectively, so it should operate on the IR first. - PM.add(createWholeProgramDevirtPass(nullptr, ImportSummary)); - PM.add(createLowerTypeTestsPass(nullptr, ImportSummary)); - } - - populateModulePassManager(PM); - - if (VerifyOutput) - PM.add(createVerifierPass()); - PerformThinLTO = false; -} - -void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) { - if (LibraryInfo) - PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); - - if (VerifyInput) - PM.add(createVerifierPass()); - - addExtensionsToPM(EP_FullLinkTimeOptimizationEarly, PM); - - if (OptLevel != 0) - addLTOOptimizationPasses(PM); - else { - // The whole-program-devirt pass needs to run at -O0 because only it knows - // about the llvm.type.checked.load intrinsic: it needs to both lower the - // intrinsic itself and handle it in the summary. - PM.add(createWholeProgramDevirtPass(ExportSummary, nullptr)); - } - - // Create a function that performs CFI checks for cross-DSO calls with targets - // in the current module. - PM.add(createCrossDSOCFIPass()); - - // Lower type metadata and the type.test intrinsic. This pass supports Clang's - // control flow integrity mechanisms (-fsanitize=cfi*) and needs to run at - // link time if CFI is enabled. The pass does nothing if CFI is disabled. - PM.add(createLowerTypeTestsPass(ExportSummary, nullptr)); - // Run a second time to clean up any type tests left behind by WPD for use - // in ICP (which is performed earlier than this in the regular LTO pipeline). - PM.add(createLowerTypeTestsPass(nullptr, nullptr, true)); - - if (OptLevel != 0) - addLateLTOOptimizationPasses(PM); - - addExtensionsToPM(EP_FullLinkTimeOptimizationLast, PM); - - PM.add(createAnnotationRemarksLegacyPass()); - - if (VerifyOutput) - PM.add(createVerifierPass()); -} - LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { PassManagerBuilder *PMB = new PassManagerBuilder(); return wrap(PMB); @@ -1231,18 +1157,3 @@ LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, legacy::PassManagerBase *MPM = unwrap(PM); Builder->populateModulePassManager(*MPM); } - -void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, - LLVMPassManagerRef PM, - LLVMBool Internalize, - LLVMBool RunInliner) { - PassManagerBuilder *Builder = unwrap(PMB); - legacy::PassManagerBase *LPM = unwrap(PM); - - // A small backwards compatibility hack. populateLTOPassManager used to take - // an RunInliner option. - if (RunInliner && !Builder->Inliner) - Builder->Inliner = createFunctionInliningPass(); - - Builder->populateLTOPassManager(*LPM); -} diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp index 937ec232..7c43255 100644 --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -68,10 +68,6 @@ static cl::list PassList(cl::desc("Passes available:"), cl::ZeroOrMore); static cl::opt - StandardLinkOpts("std-link-opts", - cl::desc("Include the standard link time optimizations")); - -static cl::opt OptLevelO1("O1", cl::desc("Optimization level 1. Identical to 'opt -O1'")); static cl::opt @@ -203,12 +199,6 @@ int main(int argc, char **argv) { AddToDriver PM(D); - if (StandardLinkOpts) { - PassManagerBuilder Builder; - Builder.Inliner = createFunctionInliningPass(); - Builder.populateLTOPassManager(PM); - } - if (OptLevelO1) AddOptimizationPasses(PM, 1, 0); else if (OptLevelO2) -- 2.7.4