diff --git a/clang/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp b/clang/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp --- a/clang/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp +++ b/clang/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp @@ -48,7 +48,6 @@ initializeAnalysis(Registry); initializeTransformUtils(Registry); initializeInstCombine(Registry); - initializeAggressiveInstCombine(Registry); initializeTarget(Registry); CLArgs.push_back("-O2"); diff --git a/llvm/bindings/python/llvm/core.py b/llvm/bindings/python/llvm/core.py --- a/llvm/bindings/python/llvm/core.py +++ b/llvm/bindings/python/llvm/core.py @@ -464,9 +464,6 @@ library.LLVMInitializeInstCombine.argtypes = [PassRegistry] library.LLVMInitializeInstCombine.restype = None - library.LLVMInitializeAggressiveInstCombiner.argtypes = [PassRegistry] - library.LLVMInitializeAggressiveInstCombiner.restype = None - library.LLVMInitializeIPO.argtypes = [PassRegistry] library.LLVMInitializeIPO.restype = None diff --git a/llvm/include/llvm-c/Initialization.h b/llvm/include/llvm-c/Initialization.h --- a/llvm/include/llvm-c/Initialization.h +++ b/llvm/include/llvm-c/Initialization.h @@ -35,7 +35,6 @@ void LLVMInitializeScalarOpts(LLVMPassRegistryRef R); void LLVMInitializeVectorization(LLVMPassRegistryRef R); void LLVMInitializeInstCombine(LLVMPassRegistryRef R); -void LLVMInitializeAggressiveInstCombiner(LLVMPassRegistryRef R); void LLVMInitializeIPO(LLVMPassRegistryRef R); void LLVMInitializeAnalysis(LLVMPassRegistryRef R); void LLVMInitializeIPA(LLVMPassRegistryRef R); diff --git a/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h b/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h deleted file mode 100644 --- a/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h +++ /dev/null @@ -1,40 +0,0 @@ -/*===-- AggressiveInstCombine.h ---------------------------------*- C++ -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This header declares the C interface to libLLVMAggressiveInstCombine.a, *| -|* which combines instructions to form fewer, simple IR instructions. *| -|* *| -\*===----------------------------------------------------------------------===*/ - -#ifndef LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H -#define LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H - -#include "llvm-c/ExternC.h" -#include "llvm-c/Types.h" - -LLVM_C_EXTERN_C_BEGIN - -/** - * @defgroup LLVMCTransformsAggressiveInstCombine Aggressive Instruction Combining transformations - * @ingroup LLVMCTransforms - * - * @{ - */ - -/** See llvm::createAggressiveInstCombinerPass function. */ -void LLVMAddAggressiveInstCombinerPass(LLVMPassManagerRef PM); - -/** - * @} - */ - -LLVM_C_EXTERN_C_END - -#endif - diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -33,9 +33,6 @@ /// Initialize all passes linked into the InstCombine library. void initializeInstCombine(PassRegistry&); -/// Initialize all passes linked into the AggressiveInstCombine library. -void initializeAggressiveInstCombine(PassRegistry&); - /// Initialize all passes linked into the IPO library. void initializeIPO(PassRegistry&); @@ -56,7 +53,6 @@ void initializeADCELegacyPassPass(PassRegistry&); void initializeAddDiscriminatorsLegacyPassPass(PassRegistry&); void initializeAddFSDiscriminatorsPass(PassRegistry &); -void initializeAggressiveInstCombinerLegacyPassPass(PassRegistry&); void initializeAliasSetPrinterPass(PassRegistry&); void initializeAlignmentFromAssumptionsPass(PassRegistry&); void initializeAlwaysInlinerLegacyPassPass(PassRegistry&); diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h --- a/llvm/include/llvm/LinkAllPasses.h +++ b/llvm/include/llvm/LinkAllPasses.h @@ -72,7 +72,6 @@ (void) llvm::createAAEvalPass(); (void) llvm::createAggressiveDCEPass(); - (void) llvm::createAggressiveInstCombinerPass(); (void) llvm::createBitTrackingDCEPass(); (void)llvm::createOpenMPOptCGSCCLegacyPass(); (void) llvm::createAlignmentFromAssumptionsPass(); diff --git a/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h b/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h --- a/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h +++ b/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h @@ -7,10 +7,8 @@ //===----------------------------------------------------------------------===// /// \file /// -/// This file provides the primary interface to the aggressive instcombine pass. -/// This pass is suitable for use in the new pass manager. For a pass that works -/// with the legacy pass manager, please use -/// \c createAggressiveInstCombinerPass(). +/// AggressiveInstCombiner - Combine expression patterns to form expressions +/// with fewer, simple instructions. This pass does not modify the CFG. /// //===----------------------------------------------------------------------===// @@ -21,22 +19,11 @@ namespace llvm { -class Function; -class FunctionPass; - class AggressiveInstCombinePass : public PassInfoMixin { - public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; - -//===----------------------------------------------------------------------===// -// -// AggressiveInstCombiner - Combine expression patterns to form expressions with -// fewer, simple instructions. This pass does not modify the CFG. -// -FunctionPass *createAggressiveInstCombinerPass(); } #endif diff --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp --- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp +++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp @@ -14,8 +14,6 @@ #include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h" #include "AggressiveInstCombineInternal.h" -#include "llvm-c/Initialization.h" -#include "llvm-c/Transforms/AggressiveInstCombine.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" @@ -24,23 +22,17 @@ #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Analysis/ValueTracking.h" +#include "llvm/IR/DataLayout.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/PatternMatch.h" -#include "llvm/InitializePasses.h" -#include "llvm/Pass.h" #include "llvm/Transforms/Utils/BuildLibCalls.h" #include "llvm/Transforms/Utils/Local.h" using namespace llvm; using namespace PatternMatch; -namespace llvm { -class DataLayout; -} - #define DEBUG_TYPE "aggressive-instcombine" STATISTIC(NumAnyOrAllBitsSet, "Number of any/all-bits-set patterns folded"); @@ -54,32 +46,6 @@ "aggressive-instcombine-max-scan-instrs", cl::init(64), cl::Hidden, cl::desc("Max number of instructions to scan for aggressive instcombine.")); -namespace { -/// Contains expression pattern combiner logic. -/// This class provides both the logic to combine expression patterns and -/// combine them. It differs from InstCombiner class in that each pattern -/// combiner runs only once as opposed to InstCombine's multi-iteration, -/// which allows pattern combiner to have higher complexity than the O(1) -/// required by the instruction combiner. -class AggressiveInstCombinerLegacyPass : public FunctionPass { -public: - static char ID; // Pass identification, replacement for typeid - - AggressiveInstCombinerLegacyPass() : FunctionPass(ID) { - initializeAggressiveInstCombinerLegacyPassPass( - *PassRegistry::getPassRegistry()); - } - - void getAnalysisUsage(AnalysisUsage &AU) const override; - - /// Run all expression pattern optimizations on the given /p F function. - /// - /// \param F function to optimize. - /// \returns true if the IR is changed. - bool runOnFunction(Function &F) override; -}; -} // namespace - /// Match a pattern for a bitwise funnel/rotate operation that partially guards /// against undefined behavior by branching around the funnel-shift/rotation /// when the shift amount is 0. @@ -894,29 +860,6 @@ return MadeChange; } -void AggressiveInstCombinerLegacyPass::getAnalysisUsage( - AnalysisUsage &AU) const { - AU.setPreservesCFG(); - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addRequired(); -} - -bool AggressiveInstCombinerLegacyPass::runOnFunction(Function &F) { - auto &AC = getAnalysis().getAssumptionCache(F); - auto &TLI = getAnalysis().getTLI(F); - auto &DT = getAnalysis().getDomTree(); - auto &TTI = getAnalysis().getTTI(F); - auto &AA = getAnalysis().getAAResults(); - return runImpl(F, AC, TTI, TLI, DT, AA); -} - PreservedAnalyses AggressiveInstCombinePass::run(Function &F, FunctionAnalysisManager &AM) { auto &AC = AM.getResult(F); @@ -933,31 +876,3 @@ PA.preserveSet(); return PA; } - -char AggressiveInstCombinerLegacyPass::ID = 0; -INITIALIZE_PASS_BEGIN(AggressiveInstCombinerLegacyPass, - "aggressive-instcombine", - "Combine pattern based expressions", false, false) -INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) -INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) -INITIALIZE_PASS_END(AggressiveInstCombinerLegacyPass, "aggressive-instcombine", - "Combine pattern based expressions", false, false) - -// Initialization Routines -void llvm::initializeAggressiveInstCombine(PassRegistry &Registry) { - initializeAggressiveInstCombinerLegacyPassPass(Registry); -} - -void LLVMInitializeAggressiveInstCombiner(LLVMPassRegistryRef R) { - initializeAggressiveInstCombinerLegacyPassPass(*unwrap(R)); -} - -FunctionPass *llvm::createAggressiveInstCombinerPass() { - return new AggressiveInstCombinerLegacyPass(); -} - -void LLVMAddAggressiveInstCombinerPass(LLVMPassManagerRef PM) { - unwrap(PM)->add(createAggressiveInstCombinerPass()); -} diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -336,8 +336,6 @@ createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp( true))); // Merge & remove BBs // Combine silly seq's - if (OptLevel > 2) - MPM.add(createAggressiveInstCombinerPass()); MPM.add(createInstructionCombiningPass()); if (SizeLevel == 0 && !DisableLibCallsShrinkWrap) MPM.add(createLibCallsShrinkWrapPass()); diff --git a/llvm/test/Transforms/PhaseOrdering/X86/pr52078.ll b/llvm/test/Transforms/PhaseOrdering/X86/pr52078.ll --- a/llvm/test/Transforms/PhaseOrdering/X86/pr52078.ll +++ b/llvm/test/Transforms/PhaseOrdering/X86/pr52078.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -O2 -S < %s | FileCheck %s -; RUN: opt -instcombine -S < %s | FileCheck %s --check-prefix=IC -; RUN: opt -aggressive-instcombine -instcombine -S < %s | FileCheck %s --check-prefix=AIC_AND_IC +; RUN: opt -passes=instcombine -S < %s | FileCheck %s --check-prefix=IC +; RUN: opt -passes=aggressive-instcombine,instcombine -S < %s | FileCheck %s --check-prefix=AIC_AND_IC target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/PhaseOrdering/X86/pr52253.ll b/llvm/test/Transforms/PhaseOrdering/X86/pr52253.ll --- a/llvm/test/Transforms/PhaseOrdering/X86/pr52253.ll +++ b/llvm/test/Transforms/PhaseOrdering/X86/pr52253.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -O3 -S < %s | FileCheck %s -; RUN: opt -instcombine -sccp -bdce -S < %s | FileCheck %s -; RUN: opt -aggressive-instcombine -instcombine -sccp -bdce -S < %s | FileCheck %s +; RUN: opt -passes=instcombine,sccp,bdce -S < %s | FileCheck %s +; RUN: opt -passes=aggressive-instcombine,instcombine,sccp,bdce -S < %s | FileCheck %s target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -148,7 +148,6 @@ initializeAnalysis(Registry); initializeTransformUtils(Registry); initializeInstCombine(Registry); - initializeAggressiveInstCombine(Registry); initializeTarget(Registry); if (std::getenv("bar") == (char*) -1) { diff --git a/llvm/tools/llvm-c-test/include-all.c b/llvm/tools/llvm-c-test/include-all.c --- a/llvm/tools/llvm-c-test/include-all.c +++ b/llvm/tools/llvm-c-test/include-all.c @@ -35,7 +35,6 @@ #include "llvm-c/Support.h" #include "llvm-c/Target.h" #include "llvm-c/TargetMachine.h" -#include "llvm-c/Transforms/AggressiveInstCombine.h" #include "llvm-c/Transforms/InstCombine.h" #include "llvm-c/Transforms/IPO.h" #include "llvm-c/Transforms/PassManagerBuilder.h" diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -197,7 +197,6 @@ initializeAnalysis(Registry); initializeTransformUtils(Registry); initializeInstCombine(Registry); - initializeAggressiveInstCombine(Registry); initializeTarget(Registry); // Parse input options diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -499,7 +499,6 @@ initializeAnalysis(Registry); initializeTransformUtils(Registry); initializeInstCombine(Registry); - initializeAggressiveInstCombine(Registry); initializeTarget(Registry); // For codegen passes, only passes that do IR to IR transformation are // supported.