|
110 | 110 | #include "llvm/Target/CGPassBuilderOption.h" |
111 | 111 | #include "llvm/Target/TargetMachine.h" |
112 | 112 | #include "llvm/Transforms/CFGuard.h" |
| 113 | +#include "llvm/Transforms/ObjCARC.h" |
113 | 114 | #include "llvm/Transforms/Scalar/ConstantHoisting.h" |
114 | 115 | #include "llvm/Transforms/Scalar/LoopPassManager.h" |
115 | 116 | #include "llvm/Transforms/Scalar/LoopStrengthReduce.h" |
| 117 | +#include "llvm/Transforms/Scalar/LoopTermFold.h" |
116 | 118 | #include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h" |
117 | 119 | #include "llvm/Transforms/Scalar/MergeICmps.h" |
118 | 120 | #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h" |
119 | 121 | #include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h" |
| 122 | +#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h" |
120 | 123 | #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" |
121 | 124 | #include "llvm/Transforms/Utils/LowerInvoke.h" |
122 | 125 | #include <cassert> |
@@ -691,7 +694,12 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( |
691 | 694 |
|
692 | 695 | // Run loop strength reduction before anything else. |
693 | 696 | if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) { |
694 | | - addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(), |
| 697 | + LoopPassManager LPM; |
| 698 | + LPM.addPass(CanonicalizeFreezeInLoopsPass()); |
| 699 | + LPM.addPass(LoopStrengthReducePass()); |
| 700 | + if (Opt.EnableLoopTermFold) |
| 701 | + LPM.addPass(LoopTermFoldPass()); |
| 702 | + addPass(createFunctionToLoopPassAdaptor(std::move(LPM), |
695 | 703 | /*UseMemorySSA=*/true)); |
696 | 704 | } |
697 | 705 |
|
@@ -736,7 +744,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( |
736 | 744 | addPass(ScalarizeMaskedMemIntrinPass()); |
737 | 745 |
|
738 | 746 | // Expand reduction intrinsics into shuffle sequences if the target wants to. |
739 | | - addPass(ExpandReductionsPass()); |
| 747 | + if (!Opt.DisableExpandReductions) |
| 748 | + addPass(ExpandReductionsPass()); |
740 | 749 |
|
741 | 750 | // Convert conditional moves to conditional jumps when profitable. |
742 | 751 | if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize) |
@@ -811,6 +820,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare( |
811 | 820 | AddIRPass &addPass) const { |
812 | 821 | derived().addPreISel(addPass); |
813 | 822 |
|
| 823 | + if (getOptLevel() != CodeGenOptLevel::None) |
| 824 | + addPass(ObjCARCContractPass()); |
| 825 | + |
814 | 826 | addPass(CallBrPreparePass()); |
815 | 827 | // Add both the safe stack and the stack protection passes: each of them will |
816 | 828 | // only protect functions that have corresponding attributes. |
|
0 commit comments