Reland [LegacyPM] Remove some legacy passes

These are part of the optimization pipeline, of which the legacy pass manager version is deprecated.

Namely
* Internalize
* StripSymbols
* StripNonDebugSymbols
* StripDeadDebugInfo
* StripDeadPrototypes
* VectorCombine
* WarnMissedTransformations

Fixed previously failing ocaml tests (one of them seems to already be failing?)
This commit is contained in:
Arthur Eubanks 2022-12-20 13:36:20 -08:00
parent a2569a76e0
commit 15977742d3
23 changed files with 1 additions and 523 deletions

View File

@ -67,20 +67,3 @@ value llvm_add_ipsccp(LLVMPassManagerRef PM) {
return Val_unit;
}
/* [`Module] Llvm.PassManager.t -> all_but_main:bool -> unit */
value llvm_add_internalize(LLVMPassManagerRef PM, value AllButMain) {
LLVMAddInternalizePass(PM, Bool_val(AllButMain));
return Val_unit;
}
/* [`Module] Llvm.PassManager.t -> unit */
value llvm_add_strip_dead_prototypes(LLVMPassManagerRef PM) {
LLVMAddStripDeadPrototypesPass(PM);
return Val_unit;
}
/* [`Module] Llvm.PassManager.t -> unit */
value llvm_add_strip_symbols(LLVMPassManagerRef PM) {
LLVMAddStripSymbolsPass(PM);
return Val_unit;
}

View File

@ -30,12 +30,3 @@ external add_global_optimizer
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ipsccp"
external add_internalize
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
= "llvm_add_internalize"
external add_strip_dead_prototypes
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_dead_prototypes"
external add_strip_symbols
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_symbols"

View File

@ -50,18 +50,3 @@ external add_global_optimizer
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ipsccp"
(** See the [llvm::createInternalizePass] function. *)
external add_internalize
: [ `Module ] Llvm.PassManager.t -> all_but_main:bool -> unit
= "llvm_add_internalize"
(** See the [llvm::createStripDeadPrototypesPass] function. *)
external add_strip_dead_prototypes
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_dead_prototypes"
(** See the [llvm::createStripSymbolsPass] function. *)
external add_strip_symbols
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_strip_symbols"

View File

@ -51,30 +51,6 @@ void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
/** See llvm::createIPSCCPPass function. */
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
/** See llvm::createInternalizePass function. */
void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
/**
* Create and add the internalize pass to the given pass manager with the
* provided preservation callback.
*
* The context parameter is forwarded to the callback on each invocation.
* As such, it is the responsibility of the caller to extend its lifetime
* until execution of this pass has finished.
*
* @see llvm::createInternalizePass function.
*/
void LLVMAddInternalizePassWithMustPreservePredicate(
LLVMPassManagerRef PM,
void *Context,
LLVMBool (*MustPreserve)(LLVMValueRef, void *));
/** See llvm::createStripDeadPrototypesPass function. */
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
/** See llvm::createStripSymbolsPass function. */
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
/**
* @}
*/

View File

@ -175,7 +175,6 @@ void initializeInstructionCombiningPassPass(PassRegistry&);
void initializeInstructionSelectPass(PassRegistry&);
void initializeInterleavedAccessPass(PassRegistry&);
void initializeInterleavedLoadCombinePass(PassRegistry &);
void initializeInternalizeLegacyPassPass(PassRegistry&);
void initializeIntervalPartitionPass(PassRegistry&);
void initializeJMCInstrumenterPass(PassRegistry&);
void initializeJumpThreadingPass(PassRegistry&);
@ -380,12 +379,8 @@ void initializeStackSafetyGlobalInfoWrapperPassPass(PassRegistry &);
void initializeStackSafetyInfoWrapperPassPass(PassRegistry &);
void initializeStackSlotColoringPass(PassRegistry&);
void initializeStraightLineStrengthReduceLegacyPassPass(PassRegistry &);
void initializeStripDeadDebugInfoPass(PassRegistry&);
void initializeStripDeadPrototypesLegacyPassPass(PassRegistry&);
void initializeStripDebugDeclarePass(PassRegistry&);
void initializeStripDebugMachineModulePass(PassRegistry &);
void initializeStripGCRelocatesLegacyPass(PassRegistry &);
void initializeStripNonDebugSymbolsPass(PassRegistry&);
void initializeStripNonLineTableDebugLegacyPassPass(PassRegistry &);
void initializeStripSymbolsPass(PassRegistry&);
void initializeStructurizeCFGLegacyPassPass(PassRegistry &);
@ -404,11 +399,9 @@ void initializeUnifyLoopExitsLegacyPassPass(PassRegistry &);
void initializeUnpackMachineBundlesPass(PassRegistry&);
void initializeUnreachableBlockElimLegacyPassPass(PassRegistry&);
void initializeUnreachableMachineBlockElimPass(PassRegistry&);
void initializeVectorCombineLegacyPassPass(PassRegistry&);
void initializeVerifierLegacyPassPass(PassRegistry&);
void initializeVirtRegMapPass(PassRegistry&);
void initializeVirtRegRewriterPass(PassRegistry&);
void initializeWarnMissedTransformationsLegacyPass(PassRegistry &);
void initializeWasmEHPreparePass(PassRegistry&);
void initializeWinEHPreparePass(PassRegistry&);
void initializeWriteBitcodePassPass(PassRegistry&);

View File

@ -104,7 +104,6 @@ namespace {
(void) llvm::createIndVarSimplifyPass();
(void) llvm::createInstSimplifyLegacyPass();
(void) llvm::createInstructionCombiningPass();
(void) llvm::createInternalizePass();
(void) llvm::createJMCInstrumenterPass();
(void) llvm::createLCSSAPass();
(void) llvm::createLegacyDivergenceAnalysisPass();
@ -148,10 +147,6 @@ namespace {
(void) llvm::createSafeStackPass();
(void) llvm::createSROAPass();
(void) llvm::createSingleLoopExtractorPass();
(void) llvm::createStripSymbolsPass();
(void) llvm::createStripNonDebugSymbolsPass();
(void) llvm::createStripDeadDebugInfoPass();
(void) llvm::createStripDeadPrototypesPass();
(void) llvm::createTailCallEliminationPass();
(void)llvm::createTLSVariableHoistPass();
(void) llvm::createJumpThreadingPass();
@ -191,7 +186,6 @@ namespace {
(void) llvm::createLoopVectorizePass();
(void) llvm::createSLPVectorizerPass();
(void) llvm::createLoadStoreVectorizerPass();
(void) llvm::createVectorCombinePass();
(void) llvm::createPartiallyInlineLibCallsPass();
(void) llvm::createScalarizerPass();
(void) llvm::createSeparateConstOffsetFromGEPPass();
@ -205,7 +199,6 @@ namespace {
(void) llvm::createFloat2IntPass();
(void) llvm::createEliminateAvailableExternallyPass();
(void)llvm::createScalarizeMaskedMemIntrinLegacyPass();
(void) llvm::createWarnMissedTransformationsPass();
(void) llvm::createHardwareLoopsPass();
(void) llvm::createInjectTLIMappingsLegacyPass();
(void) llvm::createUnifyLoopExitsPass();

View File

@ -34,30 +34,6 @@ class raw_ostream;
//
ModulePass *createAnnotation2MetadataLegacyPass();
//===----------------------------------------------------------------------===//
//
// These functions removes symbols from functions and modules. If OnlyDebugInfo
// is true, only debugging information is removed from the module.
//
ModulePass *createStripSymbolsPass(bool OnlyDebugInfo = false);
//===----------------------------------------------------------------------===//
//
// These functions strips symbols from functions and modules.
// Only debugging information is not stripped.
//
ModulePass *createStripNonDebugSymbolsPass();
//===----------------------------------------------------------------------===//
//
// This pass removes llvm.dbg.declare intrinsics.
ModulePass *createStripDebugDeclarePass();
//===----------------------------------------------------------------------===//
//
// This pass removes unused symbols' debug info.
ModulePass *createStripDeadDebugInfoPass();
//===----------------------------------------------------------------------===//
/// createConstantMergePass - This function returns a new pass that merges
/// duplicate global constants together into a single constant that is shared.
@ -110,24 +86,6 @@ Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
bool DisableInlineHotCallSite);
Pass *createFunctionInliningPass(InlineParams &Params);
//===----------------------------------------------------------------------===//
/// createInternalizePass - This pass loops over all of the functions in the
/// input module, internalizing all globals (functions and variables) it can.
////
/// Before internalizing a symbol, the callback \p MustPreserveGV is invoked and
/// gives to the client the ability to prevent internalizing specific symbols.
///
/// The symbol in DSOList are internalized if it is safe to drop them from
/// the symbol table.
///
/// Note that commandline options that are used with the above function are not
/// used now!
ModulePass *
createInternalizePass(std::function<bool(const GlobalValue &)> MustPreserveGV);
/// createInternalizePass - Same as above, but with an empty exportList.
ModulePass *createInternalizePass();
//===----------------------------------------------------------------------===//
/// createDeadArgEliminationPass - This pass removes arguments from functions
/// which are not used by the body of the function.
@ -158,10 +116,6 @@ Pass *createLoopExtractorPass();
///
Pass *createSingleLoopExtractorPass();
/// createStripDeadPrototypesPass - This pass removes any function declarations
/// (prototypes) that are not used.
ModulePass *createStripDeadPrototypesPass();
//===----------------------------------------------------------------------===//
/// createReversePostOrderFunctionAttrsPass - This pass walks SCCs of the call
/// graph in RPO to deduce and propagate function attributes. Currently it

View File

@ -522,13 +522,6 @@ FunctionPass *createLibCallsShrinkWrapPass();
//
Pass *createLoopSimplifyCFGPass();
//===----------------------------------------------------------------------===//
//
// WarnMissedTransformations - This pass emits warnings for leftover forced
// transformations.
//
Pass *createWarnMissedTransformationsPass();
//===----------------------------------------------------------------------===//
//
// This pass does instruction simplification on each

View File

@ -16,10 +16,6 @@
#include "llvm/IR/PassManager.h"
namespace llvm {
class Function;
class Pass;
class PassRegistry;
// New pass manager boilerplate.
class WarnMissedTransformationsPass
: public PassInfoMixin<WarnMissedTransformationsPass> {
@ -28,10 +24,6 @@ public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
// Legacy pass manager boilerplate.
Pass *createWarnMissedTransformationsPass();
void initializeWarnMissedTransformationsLegacyPass(PassRegistry &);
} // end namespace llvm
#endif // LLVM_TRANSFORMS_SCALAR_WARNMISSEDTRANSFORMS_H

View File

@ -100,10 +100,6 @@ FunctionPass *createPromoteMemoryToRegisterPass();
Pass *createLoopSimplifyPass();
extern char &LoopSimplifyID;
/// This function returns a new pass that downgrades the debug info in the
/// module to line tables only.
ModulePass *createStripNonLineTableDebugLegacyPass();
//===----------------------------------------------------------------------===//
//
// InjectTLIMappingsLegacy - populates the VFABI attribute with the

View File

@ -138,12 +138,6 @@ bool vectorizeBasicBlock(Pass *P, BasicBlock &BB,
//
Pass *createLoadStoreVectorizerPass();
//===----------------------------------------------------------------------===//
//
// Optimize partial vector operations using target cost models.
//
Pass *createVectorCombinePass();
} // End llvm namespace
#endif

View File

@ -35,7 +35,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeAlwaysInlinerLegacyPassPass(Registry);
initializeSimpleInlinerPass(Registry);
initializeInferFunctionAttrsLegacyPassPass(Registry);
initializeInternalizeLegacyPassPass(Registry);
initializeLoopExtractorLegacyPassPass(Registry);
initializeSingleLoopExtractorPass(Registry);
initializeAttributorLegacyPassPass(Registry);
@ -43,11 +42,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializePostOrderFunctionAttrsLegacyPassPass(Registry);
initializeReversePostOrderFunctionAttrsLegacyPassPass(Registry);
initializeIPSCCPLegacyPassPass(Registry);
initializeStripDeadPrototypesLegacyPassPass(Registry);
initializeStripSymbolsPass(Registry);
initializeStripDebugDeclarePass(Registry);
initializeStripDeadDebugInfoPass(Registry);
initializeStripNonDebugSymbolsPass(Registry);
initializeBarrierNoopPass(Registry);
initializeEliminateAvailableExternallyLegacyPassPass(Registry);
}
@ -87,27 +81,3 @@ void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createIPSCCPPass());
}
void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
auto PreserveMain = [=](const GlobalValue &GV) {
return AllButMain && GV.getName() == "main";
};
unwrap(PM)->add(createInternalizePass(PreserveMain));
}
void LLVMAddInternalizePassWithMustPreservePredicate(
LLVMPassManagerRef PM,
void *Context,
LLVMBool (*Pred)(LLVMValueRef, void *)) {
unwrap(PM)->add(createInternalizePass([=](const GlobalValue &GV) {
return Pred(wrap(&GV), Context) == 0 ? false : true;
}));
}
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createStripDeadPrototypesPass());
}
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createStripSymbolsPass());
}

View File

@ -284,48 +284,3 @@ PreservedAnalyses InternalizePass::run(Module &M, ModuleAnalysisManager &AM) {
PA.preserve<CallGraphAnalysis>();
return PA;
}
namespace {
class InternalizeLegacyPass : public ModulePass {
// Client supplied callback to control wheter a symbol must be preserved.
std::function<bool(const GlobalValue &)> MustPreserveGV;
public:
static char ID; // Pass identification, replacement for typeid
InternalizeLegacyPass() : ModulePass(ID), MustPreserveGV(PreserveAPIList()) {}
InternalizeLegacyPass(std::function<bool(const GlobalValue &)> MustPreserveGV)
: ModulePass(ID), MustPreserveGV(std::move(MustPreserveGV)) {
initializeInternalizeLegacyPassPass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override {
if (skipModule(M))
return false;
CallGraphWrapperPass *CGPass =
getAnalysisIfAvailable<CallGraphWrapperPass>();
CallGraph *CG = CGPass ? &CGPass->getCallGraph() : nullptr;
return internalizeModule(M, MustPreserveGV, CG);
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
AU.addPreserved<CallGraphWrapperPass>();
}
};
}
char InternalizeLegacyPass::ID = 0;
INITIALIZE_PASS(InternalizeLegacyPass, "internalize",
"Internalize Global Symbols", false, false)
ModulePass *llvm::createInternalizePass() {
return new InternalizeLegacyPass();
}
ModulePass *llvm::createInternalizePass(
std::function<bool(const GlobalValue &)> MustPreserveGV) {
return new InternalizeLegacyPass(std::move(MustPreserveGV));
}

View File

@ -214,7 +214,6 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
// across the loop nests.
PM.add(createLoopUnrollPass(OptLevel, DisableUnrollLoops,
ForgetAllSCEVInLoopUnroll));
PM.add(createWarnMissedTransformationsPass());
}
if (!IsFullLTO) {
@ -253,9 +252,6 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
PM.add(createSLPVectorizerPass());
}
// Enhance/cleanup vector code.
PM.add(createVectorCombinePass());
if (!IsFullLTO) {
PM.add(createInstructionCombiningPass());
@ -274,8 +270,6 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
PM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
}
PM.add(createWarnMissedTransformationsPass());
}
// After vectorization and unrolling, assume intrinsics may tell us more
@ -409,9 +403,6 @@ void PassManagerBuilder::populateModulePassManager(
addVectorPasses(MPM, /* IsFullLTO */ false);
// FIXME: We shouldn't bother with this anymore.
MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
// GlobalOpt already deletes dead functions and globals, at -O2 try a
// late pass of GlobalDCE. It is capable of deleting dead cycles.
if (OptLevel > 1) {

View File

@ -56,30 +56,3 @@ PreservedAnalyses StripDeadPrototypesPass::run(Module &M,
return PreservedAnalyses::none();
return PreservedAnalyses::all();
}
namespace {
class StripDeadPrototypesLegacyPass : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
StripDeadPrototypesLegacyPass() : ModulePass(ID) {
initializeStripDeadPrototypesLegacyPassPass(
*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override {
if (skipModule(M))
return false;
return stripDeadPrototypes(M);
}
};
} // end anonymous namespace
char StripDeadPrototypesLegacyPass::ID = 0;
INITIALIZE_PASS(StripDeadPrototypesLegacyPass, "strip-dead-prototypes",
"Strip Unused Function Prototypes", false, false)
ModulePass *llvm::createStripDeadPrototypesPass() {
return new StripDeadPrototypesLegacyPass();
}

View File

@ -38,102 +38,6 @@
using namespace llvm;
namespace {
class StripSymbols : public ModulePass {
bool OnlyDebugInfo;
public:
static char ID; // Pass identification, replacement for typeid
explicit StripSymbols(bool ODI = false)
: ModulePass(ID), OnlyDebugInfo(ODI) {
initializeStripSymbolsPass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
};
class StripNonDebugSymbols : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit StripNonDebugSymbols()
: ModulePass(ID) {
initializeStripNonDebugSymbolsPass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
};
class StripDebugDeclare : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit StripDebugDeclare()
: ModulePass(ID) {
initializeStripDebugDeclarePass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
};
class StripDeadDebugInfo : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit StripDeadDebugInfo()
: ModulePass(ID) {
initializeStripDeadDebugInfoPass(*PassRegistry::getPassRegistry());
}
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
};
}
char StripSymbols::ID = 0;
INITIALIZE_PASS(StripSymbols, "strip",
"Strip all symbols from a module", false, false)
ModulePass *llvm::createStripSymbolsPass(bool OnlyDebugInfo) {
return new StripSymbols(OnlyDebugInfo);
}
char StripNonDebugSymbols::ID = 0;
INITIALIZE_PASS(StripNonDebugSymbols, "strip-nondebug",
"Strip all symbols, except dbg symbols, from a module",
false, false)
ModulePass *llvm::createStripNonDebugSymbolsPass() {
return new StripNonDebugSymbols();
}
char StripDebugDeclare::ID = 0;
INITIALIZE_PASS(StripDebugDeclare, "strip-debug-declare",
"Strip all llvm.dbg.declare intrinsics", false, false)
ModulePass *llvm::createStripDebugDeclarePass() {
return new StripDebugDeclare();
}
char StripDeadDebugInfo::ID = 0;
INITIALIZE_PASS(StripDeadDebugInfo, "strip-dead-debug-info",
"Strip debug info for unused symbols", false, false)
ModulePass *llvm::createStripDeadDebugInfoPass() {
return new StripDeadDebugInfo();
}
/// OnlyUsedBy - Return true if V is only used by Usr.
static bool OnlyUsedBy(Value *V, Value *Usr) {
for (User *U : V->users())
@ -234,24 +138,6 @@ static bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
return true;
}
bool StripSymbols::runOnModule(Module &M) {
if (skipModule(M))
return false;
bool Changed = false;
Changed |= StripDebugInfo(M);
if (!OnlyDebugInfo)
Changed |= StripSymbolNames(M, false);
return Changed;
}
bool StripNonDebugSymbols::runOnModule(Module &M) {
if (skipModule(M))
return false;
return StripSymbolNames(M, true);
}
static bool stripDebugDeclareImpl(Module &M) {
Function *Declare = M.getFunction("llvm.dbg.declare");
@ -290,12 +176,6 @@ static bool stripDebugDeclareImpl(Module &M) {
return true;
}
bool StripDebugDeclare::runOnModule(Module &M) {
if (skipModule(M))
return false;
return stripDebugDeclareImpl(M);
}
/// Collects compilation units referenced by functions or lexical scopes.
/// Accepts any DIScope and uses recursive bottom-up approach to reach either
/// DISubprogram or DILexicalBlockBase.
@ -424,19 +304,6 @@ static bool stripDeadDebugInfoImpl(Module &M) {
return Changed;
}
/// Remove any debug info for global variables/functions in the given module for
/// which said global variable/function no longer exists (i.e. is null).
///
/// Debugging information is encoded in llvm IR using metadata. This is designed
/// such a way that debug info for symbols preserved even if symbols are
/// optimized away by the optimizer. This special pass removes debug info for
/// such symbols.
bool StripDeadDebugInfo::runOnModule(Module &M) {
if (skipModule(M))
return false;
return stripDeadDebugInfoImpl(M);
}
PreservedAnalyses StripSymbolsPass::run(Module &M, ModuleAnalysisManager &AM) {
StripDebugInfo(M);
StripSymbolNames(M, false);

View File

@ -71,7 +71,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeLoopRerollLegacyPassPass(Registry);
initializeLoopUnrollPass(Registry);
initializeLoopUnrollAndJamPass(Registry);
initializeWarnMissedTransformationsLegacyPass(Registry);
initializeLoopVersioningLICMLegacyPassPass(Registry);
initializeLoopIdiomRecognizeLegacyPassPass(Registry);
initializeLowerAtomicLegacyPassPass(Registry);

View File

@ -104,47 +104,3 @@ WarnMissedTransformationsPass::run(Function &F, FunctionAnalysisManager &AM) {
return PreservedAnalyses::all();
}
// Legacy pass manager boilerplate
namespace {
class WarnMissedTransformationsLegacy : public FunctionPass {
public:
static char ID;
explicit WarnMissedTransformationsLegacy() : FunctionPass(ID) {
initializeWarnMissedTransformationsLegacyPass(
*PassRegistry::getPassRegistry());
}
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
warnAboutLeftoverTransformations(&F, &LI, &ORE);
return false;
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
AU.addRequired<LoopInfoWrapperPass>();
AU.setPreservesAll();
}
};
} // end anonymous namespace
char WarnMissedTransformationsLegacy::ID = 0;
INITIALIZE_PASS_BEGIN(WarnMissedTransformationsLegacy, "transform-warning",
"Warn about non-applied transformations", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
INITIALIZE_PASS_END(WarnMissedTransformationsLegacy, "transform-warning",
"Warn about non-applied transformations", false, false)
Pass *llvm::createWarnMissedTransformationsPass() {
return new WarnMissedTransformationsLegacy();
}

View File

@ -11,39 +11,9 @@
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils.h"
using namespace llvm;
namespace {
/// This pass strips all debug info that is not related line tables.
/// The result will be the same as if the program where compiled with
/// -gline-tables-only.
struct StripNonLineTableDebugLegacyPass : public ModulePass {
static char ID; // Pass identification, replacement for typeid
StripNonLineTableDebugLegacyPass() : ModulePass(ID) {
initializeStripNonLineTableDebugLegacyPassPass(
*PassRegistry::getPassRegistry());
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
bool runOnModule(Module &M) override {
return llvm::stripNonLineTableDebugInfo(M);
}
};
}
char StripNonLineTableDebugLegacyPass::ID = 0;
INITIALIZE_PASS(StripNonLineTableDebugLegacyPass,
"strip-nonlinetable-debuginfo",
"Strip all debug info except linetables", false, false)
ModulePass *llvm::createStripNonLineTableDebugLegacyPass() {
return new StripNonLineTableDebugLegacyPass();
}
PreservedAnalyses
StripNonLineTableDebugInfoPass::run(Module &M, ModuleAnalysisManager &AM) {
llvm::stripNonLineTableDebugInfo(M);

View File

@ -37,7 +37,6 @@ void llvm::initializeTransformUtils(PassRegistry &Registry) {
initializeLowerInvokeLegacyPassPass(Registry);
initializeLowerSwitchLegacyPassPass(Registry);
initializePromoteLegacyPassPass(Registry);
initializeStripNonLineTableDebugLegacyPassPass(Registry);
initializeUnifyFunctionExitNodesLegacyPassPass(Registry);
initializeMetaRenamerPass(Registry);
initializeStripGCRelocatesLegacyPass(Registry);

View File

@ -1811,54 +1811,6 @@ bool VectorCombine::run() {
return MadeChange;
}
// Pass manager boilerplate below here.
namespace {
class VectorCombineLegacyPass : public FunctionPass {
public:
static char ID;
VectorCombineLegacyPass() : FunctionPass(ID) {
initializeVectorCombineLegacyPassPass(*PassRegistry::getPassRegistry());
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
AU.addRequired<AAResultsWrapperPass>();
AU.setPreservesCFG();
AU.addPreserved<DominatorTreeWrapperPass>();
AU.addPreserved<GlobalsAAWrapperPass>();
AU.addPreserved<AAResultsWrapperPass>();
AU.addPreserved<BasicAAWrapperPass>();
FunctionPass::getAnalysisUsage(AU);
}
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
VectorCombine Combiner(F, TTI, DT, AA, AC, false);
return Combiner.run();
}
};
} // namespace
char VectorCombineLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(VectorCombineLegacyPass, "vector-combine",
"Optimize scalar/vector ops", false,
false)
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_END(VectorCombineLegacyPass, "vector-combine",
"Optimize scalar/vector ops", false, false)
Pass *llvm::createVectorCombinePass() {
return new VectorCombineLegacyPass();
}
PreservedAnalyses VectorCombinePass::run(Function &F,
FunctionAnalysisManager &FAM) {
auto &AC = FAM.getResult<AssumptionAnalysis>(F);

View File

@ -26,7 +26,6 @@ void llvm::initializeVectorization(PassRegistry &Registry) {
initializeLoopVectorizePass(Registry);
initializeSLPVectorizerPass(Registry);
initializeLoadStoreVectorizerLegacyPassPass(Registry);
initializeVectorCombineLegacyPassPass(Registry);
}
void LLVMInitializeVectorization(LLVMPassRegistryRef R) {

View File

@ -55,9 +55,6 @@ let test_transforms () =
++ add_global_dce
++ add_global_optimizer
++ add_ipsccp
++ add_internalize ~all_but_main:true
++ add_strip_dead_prototypes
++ add_strip_symbols
++ PassManager.run_module m
++ PassManager.dispose)