|
102 | 102 | #include "llvm/Target/CGPassBuilderOption.h" |
103 | 103 | #include "llvm/Target/TargetMachine.h" |
104 | 104 | #include "llvm/Transforms/CFGuard.h" |
| 105 | +#include "llvm/Transforms/ObjCARC.h" |
105 | 106 | #include "llvm/Transforms/Scalar/ConstantHoisting.h" |
106 | 107 | #include "llvm/Transforms/Scalar/LoopPassManager.h" |
107 | 108 | #include "llvm/Transforms/Scalar/LoopStrengthReduce.h" |
| 109 | +#include "llvm/Transforms/Scalar/LoopTermFold.h" |
108 | 110 | #include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h" |
109 | 111 | #include "llvm/Transforms/Scalar/MergeICmps.h" |
110 | 112 | #include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h" |
111 | 113 | #include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h" |
| 114 | +#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h" |
112 | 115 | #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" |
113 | 116 | #include "llvm/Transforms/Utils/LowerInvoke.h" |
114 | 117 | #include <cassert> |
@@ -685,7 +688,12 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( |
685 | 688 |
|
686 | 689 | // Run loop strength reduction before anything else. |
687 | 690 | if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) { |
688 | | - addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(), |
| 691 | + LoopPassManager LPM; |
| 692 | + LPM.addPass(CanonicalizeFreezeInLoopsPass()); |
| 693 | + LPM.addPass(LoopStrengthReducePass()); |
| 694 | + if (Opt.EnableLoopTermFold) |
| 695 | + LPM.addPass(LoopTermFoldPass()); |
| 696 | + addPass(createFunctionToLoopPassAdaptor(std::move(LPM), |
689 | 697 | /*UseMemorySSA=*/true)); |
690 | 698 | } |
691 | 699 |
|
@@ -730,7 +738,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses( |
730 | 738 | addPass(ScalarizeMaskedMemIntrinPass()); |
731 | 739 |
|
732 | 740 | // Expand reduction intrinsics into shuffle sequences if the target wants to. |
733 | | - addPass(ExpandReductionsPass()); |
| 741 | + if (!Opt.DisableExpandReductions) |
| 742 | + addPass(ExpandReductionsPass()); |
734 | 743 |
|
735 | 744 | // Convert conditional moves to conditional jumps when profitable. |
736 | 745 | if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize) |
@@ -805,6 +814,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare( |
805 | 814 | AddIRPass &addPass) const { |
806 | 815 | derived().addPreISel(addPass); |
807 | 816 |
|
| 817 | + if (getOptLevel() != CodeGenOptLevel::None) |
| 818 | + addPass(ObjCARCContractPass()); |
| 819 | + |
808 | 820 | addPass(CallBrPreparePass()); |
809 | 821 | // Add both the safe stack and the stack protection passes: each of them will |
810 | 822 | // only protect functions that have corresponding attributes. |
|
0 commit comments