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