Skip to content

Commit 9aa8daa

Browse files
committed
wip: Stitch in IR passes in codegen pipeline
1 parent c419260 commit 9aa8daa

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@
102102
#include "llvm/Target/CGPassBuilderOption.h"
103103
#include "llvm/Target/TargetMachine.h"
104104
#include "llvm/Transforms/CFGuard.h"
105+
#include "llvm/Transforms/ObjCARC.h"
105106
#include "llvm/Transforms/Scalar/ConstantHoisting.h"
106107
#include "llvm/Transforms/Scalar/LoopPassManager.h"
107108
#include "llvm/Transforms/Scalar/LoopStrengthReduce.h"
109+
#include "llvm/Transforms/Scalar/LoopTermFold.h"
108110
#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
109111
#include "llvm/Transforms/Scalar/MergeICmps.h"
110112
#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
111113
#include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h"
114+
#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h"
112115
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
113116
#include "llvm/Transforms/Utils/LowerInvoke.h"
114117
#include <cassert>
@@ -685,7 +688,12 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
685688

686689
// Run loop strength reduction before anything else.
687690
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),
689697
/*UseMemorySSA=*/true));
690698
}
691699

@@ -730,7 +738,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
730738
addPass(ScalarizeMaskedMemIntrinPass());
731739

732740
// Expand reduction intrinsics into shuffle sequences if the target wants to.
733-
addPass(ExpandReductionsPass());
741+
if (!Opt.DisableExpandReductions)
742+
addPass(ExpandReductionsPass());
734743

735744
// Convert conditional moves to conditional jumps when profitable.
736745
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
@@ -805,6 +814,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare(
805814
AddIRPass &addPass) const {
806815
derived().addPreISel(addPass);
807816

817+
if (getOptLevel() != CodeGenOptLevel::None)
818+
addPass(ObjCARCContractPass());
819+
808820
addPass(CallBrPreparePass());
809821
// Add both the safe stack and the stack protection passes: each of them will
810822
// only protect functions that have corresponding attributes.

llvm/include/llvm/Target/CGPassBuilderOption.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct CGPassBuilderOption {
5151
bool EnableMachineFunctionSplitter = false;
5252
bool EnableSinkAndFold = false;
5353
bool EnableTailMerge = true;
54+
/// Enable LoopTermFold immediately after LSR
55+
bool EnableLoopTermFold = false;
5456
bool MISchedPostRA = false;
5557
bool EarlyLiveIntervals = false;
5658
bool GCEmptyBlocks = false;

0 commit comments

Comments
 (0)