These are part of the optimization pipeline, of which the legacy pass manager version is deprecated.
Namely
* Internalize
* StripSymbols
* StripNonDebugSymbols
* StripDeadDebugInfo
* StripDeadPrototypes
* VectorCombine
* WarnMissedTransformations
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;
-}
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"
/** 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);
-
/**
* @}
*/
void initializeInstructionSelectPass(PassRegistry&);
void initializeInterleavedAccessPass(PassRegistry&);
void initializeInterleavedLoadCombinePass(PassRegistry &);
-void initializeInternalizeLegacyPassPass(PassRegistry&);
void initializeIntervalPartitionPass(PassRegistry&);
void initializeJMCInstrumenterPass(PassRegistry&);
void initializeJumpThreadingPass(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 &);
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&);
(void) llvm::createIndVarSimplifyPass();
(void) llvm::createInstSimplifyLegacyPass();
(void) llvm::createInstructionCombiningPass();
- (void) llvm::createInternalizePass();
(void) llvm::createJMCInstrumenterPass();
(void) llvm::createLCSSAPass();
(void) llvm::createLegacyDivergenceAnalysisPass();
(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();
(void) llvm::createLoopVectorizePass();
(void) llvm::createSLPVectorizerPass();
(void) llvm::createLoadStoreVectorizerPass();
- (void) llvm::createVectorCombinePass();
(void) llvm::createPartiallyInlineLibCallsPass();
(void) llvm::createScalarizerPass();
(void) llvm::createSeparateConstOffsetFromGEPPass();
(void) llvm::createFloat2IntPass();
(void) llvm::createEliminateAvailableExternallyPass();
(void)llvm::createScalarizeMaskedMemIntrinLegacyPass();
- (void) llvm::createWarnMissedTransformationsPass();
(void) llvm::createHardwareLoopsPass();
(void) llvm::createInjectTLIMappingsLegacyPass();
(void) llvm::createUnifyLoopExitsPass();
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.
/// This is useful because some passes (ie TraceValues) insert a lot of string
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.
///
///
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
//===----------------------------------------------------------------------===//
//
-// WarnMissedTransformations - This pass emits warnings for leftover forced
-// transformations.
-//
-Pass *createWarnMissedTransformationsPass();
-
-//===----------------------------------------------------------------------===//
-//
// This pass does instruction simplification on each
// instruction in a function.
//
#include "llvm/IR/PassManager.h"
namespace llvm {
-class Function;
-class Pass;
-class PassRegistry;
-
// New pass manager boilerplate.
class WarnMissedTransformationsPass
: public PassInfoMixin<WarnMissedTransformationsPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
-
-// Legacy pass manager boilerplate.
-Pass *createWarnMissedTransformationsPass();
-void initializeWarnMissedTransformationsLegacyPass(PassRegistry &);
} // end namespace llvm
#endif // LLVM_TRANSFORMS_SCALAR_WARNMISSEDTRANSFORMS_H
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
//
Pass *createLoadStoreVectorizerPass();
-//===----------------------------------------------------------------------===//
-//
-// Optimize partial vector operations using target cost models.
-//
-Pass *createVectorCombinePass();
-
} // End llvm namespace
#endif
initializeAlwaysInlinerLegacyPassPass(Registry);
initializeSimpleInlinerPass(Registry);
initializeInferFunctionAttrsLegacyPassPass(Registry);
- initializeInternalizeLegacyPassPass(Registry);
initializeLoopExtractorLegacyPassPass(Registry);
initializeSingleLoopExtractorPass(Registry);
initializeAttributorLegacyPassPass(Registry);
initializePostOrderFunctionAttrsLegacyPassPass(Registry);
initializeReversePostOrderFunctionAttrsLegacyPassPass(Registry);
initializeIPSCCPLegacyPassPass(Registry);
- initializeStripDeadPrototypesLegacyPassPass(Registry);
- initializeStripSymbolsPass(Registry);
- initializeStripDebugDeclarePass(Registry);
- initializeStripDeadDebugInfoPass(Registry);
- initializeStripNonDebugSymbolsPass(Registry);
initializeBarrierNoopPass(Registry);
initializeEliminateAvailableExternallyLegacyPassPass(Registry);
}
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());
-}
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));
-}
// across the loop nests.
PM.add(createLoopUnrollPass(OptLevel, DisableUnrollLoops,
ForgetAllSCEVInLoopUnroll));
- PM.add(createWarnMissedTransformationsPass());
}
if (!IsFullLTO) {
PM.add(createSLPVectorizerPass());
}
- // Enhance/cleanup vector code.
- PM.add(createVectorCombinePass());
-
if (!IsFullLTO) {
PM.add(createInstructionCombiningPass());
PM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));
}
-
- PM.add(createWarnMissedTransformationsPass());
}
// After vectorization and unrolling, assume intrinsics may tell us more
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) {
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();
-}
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())
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");
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.
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);
initializeLoopRerollLegacyPassPass(Registry);
initializeLoopUnrollPass(Registry);
initializeLoopUnrollAndJamPass(Registry);
- initializeWarnMissedTransformationsLegacyPass(Registry);
initializeLoopVersioningLICMLegacyPassPass(Registry);
initializeLoopIdiomRecognizeLegacyPassPass(Registry);
initializeLowerAtomicLegacyPassPass(Registry);
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();
-}
#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();
-}
+using namespace llvm;
PreservedAnalyses
StripNonLineTableDebugInfoPass::run(Module &M, ModuleAnalysisManager &AM) {
initializeLowerInvokeLegacyPassPass(Registry);
initializeLowerSwitchLegacyPassPass(Registry);
initializePromoteLegacyPassPass(Registry);
- initializeStripNonLineTableDebugLegacyPassPass(Registry);
initializeUnifyFunctionExitNodesLegacyPassPass(Registry);
initializeMetaRenamerPass(Registry);
initializeStripGCRelocatesLegacyPass(Registry);
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);
initializeLoopVectorizePass(Registry);
initializeSLPVectorizerPass(Registry);
initializeLoadStoreVectorizerLegacyPassPass(Registry);
- initializeVectorCombineLegacyPassPass(Registry);
}
void LLVMInitializeVectorization(LLVMPassRegistryRef R) {