mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-19 06:38:28 +00:00
[LoopIdiomRecognize] Remove legacy pass
Following recent changes to remove non-core legacy passes.
This commit is contained in:
parent
a489e11439
commit
d7c459070c
@ -42,9 +42,6 @@ external add_jump_threading
|
||||
external add_licm
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_licm"
|
||||
external add_loop_idiom
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_loop_idiom"
|
||||
external add_loop_rotation
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_loop_rotate"
|
||||
|
@ -71,11 +71,6 @@ external add_licm
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_licm"
|
||||
|
||||
(** See the [llvm::createLoopIdiomPass] function. *)
|
||||
external add_loop_idiom
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_loop_idiom"
|
||||
|
||||
(** See the [llvm::createLoopRotatePass] function. *)
|
||||
external add_loop_rotation
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
|
@ -91,12 +91,6 @@ value llvm_add_licm(LLVMPassManagerRef PM) {
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
|
||||
value llvm_add_loop_idiom(LLVMPassManagerRef PM) {
|
||||
LLVMAddLoopIdiomPass(PM);
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
|
||||
value llvm_add_loop_rotate(LLVMPassManagerRef PM) {
|
||||
LLVMAddLoopRotatePass(PM);
|
||||
|
@ -76,9 +76,6 @@ void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
|
||||
/** See llvm::createLICMPass function. */
|
||||
void LLVMAddLICMPass(LLVMPassManagerRef PM);
|
||||
|
||||
/** See llvm::createLoopIdiomPass function */
|
||||
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
|
||||
|
||||
/** See llvm::createLoopRotatePass function. */
|
||||
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
|
||||
|
||||
|
@ -209,7 +209,6 @@ void initializeLoopAccessLegacyAnalysisPass(PassRegistry&);
|
||||
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry&);
|
||||
void initializeLoopExtractorLegacyPassPass(PassRegistry &);
|
||||
void initializeLoopGuardWideningLegacyPassPass(PassRegistry&);
|
||||
void initializeLoopIdiomRecognizeLegacyPassPass(PassRegistry&);
|
||||
void initializeLoopInfoWrapperPassPass(PassRegistry&);
|
||||
void initializeLoopInstSimplifyLegacyPassPass(PassRegistry&);
|
||||
void initializeLoopPassPass(PassRegistry&);
|
||||
|
@ -113,7 +113,6 @@ namespace {
|
||||
(void) llvm::createLoopSimplifyCFGPass();
|
||||
(void) llvm::createLoopStrengthReducePass();
|
||||
(void) llvm::createLoopUnrollPass();
|
||||
(void) llvm::createLoopIdiomPass();
|
||||
(void) llvm::createLoopRotatePass();
|
||||
(void) llvm::createLowerConstantIntrinsicsPass();
|
||||
(void) llvm::createLowerExpectIntrinsicPass();
|
||||
|
@ -176,12 +176,6 @@ Pass *createSimpleLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
|
||||
//
|
||||
Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// LoopIdiom - This pass recognizes and replaces idioms in loops.
|
||||
//
|
||||
Pass *createLoopIdiomPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
|
||||
|
@ -152,7 +152,6 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
|
||||
SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
|
||||
MPM.add(createInstructionCombiningPass());
|
||||
// We resume loop passes creating a second loop pipeline here.
|
||||
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
|
||||
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
|
||||
|
||||
// Unroll small loops and perform peeling.
|
||||
|
@ -254,62 +254,8 @@ private:
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
||||
class LoopIdiomRecognizeLegacyPass : public LoopPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
explicit LoopIdiomRecognizeLegacyPass() : LoopPass(ID) {
|
||||
initializeLoopIdiomRecognizeLegacyPassPass(
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnLoop(Loop *L, LPPassManager &LPM) override {
|
||||
if (DisableLIRP::All)
|
||||
return false;
|
||||
|
||||
if (skipLoop(L))
|
||||
return false;
|
||||
|
||||
AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
|
||||
DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||
LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
||||
ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
||||
TargetLibraryInfo *TLI =
|
||||
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
|
||||
*L->getHeader()->getParent());
|
||||
const TargetTransformInfo *TTI =
|
||||
&getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
|
||||
*L->getHeader()->getParent());
|
||||
const DataLayout *DL = &L->getHeader()->getModule()->getDataLayout();
|
||||
auto *MSSAAnalysis = getAnalysisIfAvailable<MemorySSAWrapperPass>();
|
||||
MemorySSA *MSSA = nullptr;
|
||||
if (MSSAAnalysis)
|
||||
MSSA = &MSSAAnalysis->getMSSA();
|
||||
|
||||
// For the old PM, we can't use OptimizationRemarkEmitter as an analysis
|
||||
// pass. Function analyses need to be preserved across loop transformations
|
||||
// but ORE cannot be preserved (see comment before the pass definition).
|
||||
OptimizationRemarkEmitter ORE(L->getHeader()->getParent());
|
||||
|
||||
LoopIdiomRecognize LIR(AA, DT, LI, SE, TLI, TTI, MSSA, DL, ORE);
|
||||
return LIR.runOnLoop(L);
|
||||
}
|
||||
|
||||
/// This transformation requires natural loop information & requires that
|
||||
/// loop preheaders be inserted into the CFG.
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||
AU.addPreserved<MemorySSAWrapperPass>();
|
||||
getLoopAnalysisUsage(AU);
|
||||
}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
char LoopIdiomRecognizeLegacyPass::ID = 0;
|
||||
|
||||
PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L, LoopAnalysisManager &AM,
|
||||
LoopStandardAnalysisResults &AR,
|
||||
LPMUpdater &) {
|
||||
@ -334,16 +280,6 @@ PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L, LoopAnalysisManager &AM,
|
||||
return PA;
|
||||
}
|
||||
|
||||
INITIALIZE_PASS_BEGIN(LoopIdiomRecognizeLegacyPass, "loop-idiom",
|
||||
"Recognize loop idioms", false, false)
|
||||
INITIALIZE_PASS_DEPENDENCY(LoopPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(LoopIdiomRecognizeLegacyPass, "loop-idiom",
|
||||
"Recognize loop idioms", false, false)
|
||||
|
||||
Pass *llvm::createLoopIdiomPass() { return new LoopIdiomRecognizeLegacyPass(); }
|
||||
|
||||
static void deleteDeadInstruction(Instruction *I) {
|
||||
I->replaceAllUsesWith(PoisonValue::get(I->getType()));
|
||||
I->eraseFromParent();
|
||||
|
@ -65,7 +65,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
|
||||
initializeLoopRotateLegacyPassPass(Registry);
|
||||
initializeLoopStrengthReducePass(Registry);
|
||||
initializeLoopUnrollPass(Registry);
|
||||
initializeLoopIdiomRecognizeLegacyPassPass(Registry);
|
||||
initializeLowerAtomicLegacyPassPass(Registry);
|
||||
initializeLowerConstantIntrinsicsPass(Registry);
|
||||
initializeLowerExpectIntrinsicPass(Registry);
|
||||
@ -168,10 +167,6 @@ void LLVMAddLICMPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createLICMPass());
|
||||
}
|
||||
|
||||
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createLoopIdiomPass());
|
||||
}
|
||||
|
||||
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createLoopRotatePass());
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ let test_transforms () =
|
||||
++ add_instruction_combination
|
||||
++ add_jump_threading
|
||||
++ add_licm
|
||||
++ add_loop_idiom
|
||||
++ add_loop_rotation
|
||||
++ add_loop_unroll
|
||||
++ add_memcpy_opt
|
||||
|
@ -84,7 +84,6 @@ public:
|
||||
FPM->add(createCFGSimplificationPass());
|
||||
FPM->add(createInstructionCombiningPass(true));
|
||||
FPM->add(createIndVarSimplifyPass());
|
||||
FPM->add(createLoopIdiomPass());
|
||||
FPM->add(createCFGSimplificationPass());
|
||||
FPM->add(createSimpleLoopUnrollPass(3));
|
||||
FPM->add(createMergedLoadStoreMotionPass());
|
||||
|
Loading…
x
Reference in New Issue
Block a user