Index: lib/Analysis/LoopAnalysisManager.cpp =================================================================== --- lib/Analysis/LoopAnalysisManager.cpp +++ lib/Analysis/LoopAnalysisManager.cpp @@ -20,7 +20,7 @@ namespace llvm { /// Enables memory ssa as a dependency for loop passes in legacy pass manager. cl::opt EnableMSSALoopDependency( - "enable-mssa-loop-dependency", cl::Hidden, cl::init(false), + "enable-mssa-loop-dependency", cl::Hidden, cl::init(true), cl::desc("Enable MemorySSA dependency for loop pass manager")); // Explicit template instantiations and specialization definitions for core Index: lib/Transforms/Utils/LoopUtils.cpp =================================================================== --- lib/Transforms/Utils/LoopUtils.cpp +++ lib/Transforms/Utils/LoopUtils.cpp @@ -19,6 +19,7 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/MustExecute.h" #include "llvm/Analysis/ScalarEvolution.h" @@ -169,6 +170,12 @@ AU.addPreserved(); AU.addRequired(); AU.addPreserved(); + // FIXME: enable when all loop passes preserve MemorySSA. + // Remove individual handling in each pass when that happens. + if (false) { + AU.addRequired(); + AU.addPreserved(); + } } /// Manually defined generic "LoopPass" dependency initialization. This is used @@ -189,6 +196,7 @@ INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass) INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass) INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass) + INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) } /// Find string metadata for loop Index: test/Analysis/BasicAA/store-promote.ll =================================================================== --- test/Analysis/BasicAA/store-promote.ll +++ test/Analysis/BasicAA/store-promote.ll @@ -25,10 +25,11 @@ ; The Loop block should be empty after the load/store are promoted. ; CHECK: @test1 ; CHECK: load i32, i32* @A +; CHECK: store i32 %Atmp, i32* @B ; CHECK: Loop: ; CHECK-NEXT: br i1 %c, label %Out, label %Loop ; CHECK: Out: -; CHECK: store i32 %Atmp, i32* @B +; CHECK: load i32, i32* @A } define i32 @test2(i1 %c) { Index: test/Other/loop-pm-invalidation.ll =================================================================== --- test/Other/loop-pm-invalidation.ll +++ test/Other/loop-pm-invalidation.ll @@ -67,6 +67,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -104,6 +105,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -151,6 +153,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -197,6 +200,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -260,6 +264,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -297,6 +302,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -332,6 +338,7 @@ ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: ScalarEvolutionAnalysis Index: test/Other/new-pass-manager.ll =================================================================== --- test/Other/new-pass-manager.ll +++ test/Other/new-pass-manager.ll @@ -463,6 +463,7 @@ ; CHECK-REPEAT-LOOP-PASS-NEXT: Invalidating all non-preserved analyses ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: LCSSAPass ; CHECK-REPEAT-LOOP-PASS-NEXT: Finished llvm::Function pass manager run +; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AAManager ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ScalarEvolutionAnalysis Index: test/Other/opt-O2-pipeline.ll =================================================================== --- test/Other/opt-O2-pipeline.ll +++ test/Other/opt-O2-pipeline.ll @@ -92,13 +92,15 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Invariant Code Motion @@ -153,13 +155,15 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Post-Dominator Tree Construction @@ -185,13 +189,15 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Access Analysis @@ -244,10 +250,12 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Lazy Branch Probability Analysis Index: test/Other/opt-O3-pipeline.ll =================================================================== --- test/Other/opt-O3-pipeline.ll +++ test/Other/opt-O3-pipeline.ll @@ -97,13 +97,15 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Invariant Code Motion @@ -158,13 +160,15 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Post-Dominator Tree Construction @@ -190,13 +194,15 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Access Analysis @@ -249,10 +255,12 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Lazy Branch Probability Analysis Index: test/Other/opt-Os-pipeline.ll =================================================================== --- test/Other/opt-Os-pipeline.ll +++ test/Other/opt-Os-pipeline.ll @@ -79,13 +79,15 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Invariant Code Motion @@ -140,13 +142,15 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Post-Dominator Tree Construction @@ -172,13 +176,15 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops ; CHECK-NEXT: Loop Access Analysis @@ -231,10 +237,12 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass ; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion ; CHECK-NEXT: Lazy Branch Probability Analysis Index: test/Other/opt-hot-cold-split.ll =================================================================== --- test/Other/opt-hot-cold-split.ll +++ test/Other/opt-hot-cold-split.ll @@ -17,3 +17,305 @@ ; LTO-POSTLINK-Os: HotColdSplitting ; THINLTO-POSTLINK-Os: HotColdSplitting + +; CHECK-LABEL: Pass Arguments: +; CHECK-NEXT: Target Transform Information +; CHECK-NEXT: Type-Based Alias Analysis +; CHECK-NEXT: Scoped NoAlias Alias Analysis +; CHECK-NEXT: Assumption Cache Tracker +; CHECK-NEXT: Target Library Information +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Module Verifier +; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining) +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: SROA +; CHECK-NEXT: Early CSE +; CHECK-NEXT: Lower 'expect' Intrinsics +; CHECK-NEXT: Pass Arguments: +; CHECK-NEXT: Target Library Information +; CHECK-NEXT: Target Transform Information +; Target Pass Configuration +; CHECK: Type-Based Alias Analysis +; CHECK-NEXT: Scoped NoAlias Alias Analysis +; CHECK-NEXT: Assumption Cache Tracker +; CHECK-NEXT: Profile summary info +; CHECK-NEXT: ModulePass Manager +; CHECK-NEXT: Force set function attributes +; CHECK-NEXT: Infer set function attributes +; CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation +; CHECK-NEXT: Unnamed pass: implement Pass::getPassName() +; CHECK-NEXT: Called Value Propagation +; CHECK-NEXT: Global Variable Optimizer +; CHECK-NEXT: Unnamed pass: implement Pass::getPassName() +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Promote Memory to Register +; CHECK-NEXT: Dead Argument Elimination +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: CallGraph Construction +; CHECK-NEXT: Globals Alias Analysis +; CHECK-NEXT: Call Graph SCC Pass Manager +; CHECK-NEXT: Remove unused exception handling info +; CHECK-NEXT: Function Integration/Inlining +; CHECK-NEXT: Deduce function attributes +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: SROA +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Early CSE w/ MemorySSA +; CHECK-NEXT: Speculatively execute instructions if target has divergent branches +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Lazy Value Information Analysis +; CHECK-NEXT: Jump Threading +; CHECK-NEXT: Value Propagation +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Tail Call Elimination +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Reassociate expressions +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Rotate Loops +; CHECK-NEXT: Loop Invariant Code Motion +; CHECK-NEXT: Unswitch loops +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Induction Variable Simplification +; CHECK-NEXT: Recognize loop idioms +; CHECK-NEXT: Delete dead loops +; CHECK-NEXT: Unroll loops +; CHECK-NEXT: MergedLoadStoreMotion +; CHECK-NEXT: Phi Values Analysis +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory Dependence Analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Global Value Numbering +; CHECK-NEXT: Phi Values Analysis +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory Dependence Analysis +; CHECK-NEXT: MemCpy Optimization +; CHECK-NEXT: Sparse Conditional Constant Propagation +; CHECK-NEXT: Demanded bits analysis +; CHECK-NEXT: Bit-Tracking Dead Code Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Lazy Value Information Analysis +; CHECK-NEXT: Jump Threading +; CHECK-NEXT: Value Propagation +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Phi Values Analysis +; CHECK-NEXT: Memory Dependence Analysis +; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Loop Invariant Code Motion +; CHECK-NEXT: Post-Dominator Tree Construction +; CHECK-NEXT: Aggressive Dead Code Elimination +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: A No-Op Barrier Pass +; CHECK-NEXT: Eliminate Available Externally Globals +; CHECK-NEXT: CallGraph Construction +; CHECK-NEXT: Deduce function attributes in RPO +; CHECK-NEXT: Global Variable Optimizer +; CHECK-NEXT: Unnamed pass: implement Pass::getPassName() +; CHECK-NEXT: Dead Global Elimination +; CHECK-NEXT: CallGraph Construction +; CHECK-NEXT: Globals Alias Analysis +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Float to int +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Rotate Loops +; CHECK-NEXT: Loop Access Analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Loop Distribution +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Loop Access Analysis +; CHECK-NEXT: Demanded bits analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Loop Vectorization +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Loop Access Analysis +; CHECK-NEXT: Loop Load Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Demanded bits analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: SLP Vectorizer +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Unroll loops +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Memory SSA +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Loop Invariant Code Motion +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Warn about non-applied transformations +; CHECK-NEXT: Alignment from assumptions +; CHECK-NEXT: Strip Unused Function Prototypes +; CHECK-NEXT: Dead Global Elimination +; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Canonicalize natural loops +; CHECK-NEXT: LCSSA Verifier +; CHECK-NEXT: Loop-Closed SSA Form Pass +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Scalar Evolution Analysis +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Loop Pass Manager +; CHECK-NEXT: Loop Sink +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Remove redundant instructions +; CHECK-NEXT: Hoist/decompose integer division and remainder +; CHECK-NEXT: Simplify the CFG +; CHECK-NEXT: Hot Cold Splitting +; CHECK-NEXT: Unnamed pass: implement Pass::getPassName() +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Module Verifier +; CHECK-NEXT: Bitcode Writer +; CHECK-NEXT: Pass Arguments: -domtree +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Pass Arguments: -targetlibinfo -domtree -loops -branch-prob -block-freq +; CHECK-NEXT: Target Library Information +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Pass Arguments: -targetlibinfo -domtree -loops -branch-prob -block-freq +; CHECK-NEXT: Target Library Information +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Pass Arguments: -targetlibinfo -domtree -loops -branch-prob -block-freq +; CHECK-NEXT: Target Library Information +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis Index: test/Transforms/LICM/argmemonly-call.ll =================================================================== --- test/Transforms/LICM/argmemonly-call.ll +++ test/Transforms/LICM/argmemonly-call.ll @@ -93,7 +93,7 @@ ; we clump foo_new with bar. ; With the N2 Alias analysis diagnostic tool, we are able to hoist the ; argmemonly bar call out of the loop. -; Using MemorySSA we can also hoist bar. +; Using MemorySSA we can also hoist bar. Test updated with flag flipped. define void @test5(i32* %loc2, i32* noalias %loc) { ; ALIAS-N2-LABEL: @test5 @@ -101,8 +101,8 @@ ; ALIAS-N2-LABEL: loop: ; CHECK-LABEL: @test5 -; CHECK-LABEL: loop: ; CHECK: @bar +; CHECK-LABEL: loop: br label %loop loop: Index: test/Transforms/LICM/atomics.ll =================================================================== --- test/Transforms/LICM/atomics.ll +++ test/Transforms/LICM/atomics.ll @@ -173,11 +173,10 @@ end: ret i32 %vala ; CHECK-LABEL: define i32 @test7b( -; CHECK-LABEL: entry: -; CHECK: store i32 5, i32* %x ; CHECK-LABEL: loop: ; CHECK: load atomic i32, i32* %y monotonic ; CHECK-LABEL: end: +; CHECK: store i32 5, i32* %x ; CHECK: store atomic i32 %{{.+}}, i32* %z unordered, align 4 } Index: test/Transforms/LICM/funclet.ll =================================================================== --- test/Transforms/LICM/funclet.ll +++ test/Transforms/LICM/funclet.ll @@ -100,6 +100,7 @@ ; CHECK-LABEL: forbody.preheader: ; CHECK: store i32 1, i32* %bc, align 4 ; CHECK: store i32 2, i32* %bc2, align 4 +; CHECK: br label %forbody ; CHECK: catchswitch within none ; CHECK-LABEL: forbody: Index: test/Transforms/LICM/guards.ll =================================================================== --- test/Transforms/LICM/guards.ll +++ test/Transforms/LICM/guards.ll @@ -61,13 +61,40 @@ ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ] -; CHECK-NEXT: store i32 0, i32* [[P2]] +; CHECK-NEXT: store i32 [[X]], i32* [[P2]] ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ] ; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]] ; CHECK-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]] ; CHECK-NEXT: br label [[LOOP]] ; +entry: + br label %loop + +loop: + %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ] + %p2 = getelementptr i32, i32* %ptr, i32 1 + store i32 %x, i32* %p2 + call void (i1, ...) @llvm.experimental.guard(i1 %cond) ["deopt" (i32 0)] + %val = load i32, i32* %ptr + %x.inc = add i32 %x, %val + br label %loop +} + +; But can hoist if the side effect is hoisted. +define void @test2b_prime(i1 %cond, i32* %ptr) { +; CHECK-LABEL: @test2b_prime( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[P2:%.*]] = getelementptr i32, i32* [[PTR:%.*]], i32 1 +; CHECK-NEXT: store i32 0, i32* [[P2]] +; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ] +; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]] +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]] +; CHECK-NEXT: br label [[LOOP]] + entry: br label %loop Index: test/Transforms/LICM/promote-order.ll =================================================================== --- test/Transforms/LICM/promote-order.ll +++ test/Transforms/LICM/promote-order.ll @@ -12,8 +12,8 @@ define i32* @_Z4doiti(i32 %n, float* %tmp1, i32* %tmp3) nounwind { ; CHECK-LABEL: for.body.lr.ph: ; CHECK: store float 1.000000e+00, float* %tmp1 -; CHECK-LABEL: for.cond.for.end_crit_edge: ; CHECK: store i32 1, i32* %tmp3 +; CHECK-LABEL: for.cond.for.end_crit_edge: entry: %cmp1 = icmp slt i32 0, %n Index: test/Transforms/LICM/read-only-calls.ll =================================================================== --- test/Transforms/LICM/read-only-calls.ll +++ test/Transforms/LICM/read-only-calls.ll @@ -16,12 +16,12 @@ ; hoist the load out with the n2-threshold ; since it doesn't alias with the store. ; default AST mechanism clumps all memory locations in one set because of the -; readonly call +; readonly call. Using MemorySSA we can hoist it. define void @test1(i32* %ptr) { ; CHECK-LABEL: @test1( ; CHECK-LABEL: entry: -; CHECK-LABEL: loop: ; CHECK: %val = load i32, i32* %ptr +; CHECK-LABEL: loop: ; ALIAS-N2-LABEL: @test1( ; ALIAS-N2-LABEL: entry: Index: test/Transforms/LICM/store-hoisting.ll =================================================================== --- test/Transforms/LICM/store-hoisting.ll +++ test/Transforms/LICM/store-hoisting.ll @@ -1,6 +1,6 @@ -; RUN: opt -S -basicaa -licm %s | FileCheck -check-prefixes=CHECK,AST %s +; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=false %s | FileCheck -check-prefixes=CHECK,AST %s ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true %s | FileCheck -check-prefixes=CHECK,MSSA %s -; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,AST %s +; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,MSSA %s define void @test(i32* %loc) { ; CHECK-LABEL: @test Index: test/Transforms/LoopRotate/pr35210.ll =================================================================== --- test/Transforms/LoopRotate/pr35210.ll +++ test/Transforms/LoopRotate/pr35210.ll @@ -16,6 +16,7 @@ ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f ; CHECK-NEXT: Running pass: LCSSAPass on f ; CHECK-NEXT: Finished llvm::Function pass manager run. +; CHECK-NEXT: Running analysis: MemorySSAAnalysis on f ; CHECK-NEXT: Running analysis: AAManager on f ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f