[PATCH] D105517: [AMDGPU] isPassEnabled() helper to check cl::opt and OptLevel
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 6 22:15:29 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb16400449fc7: [AMDGPU] isPassEnabled() helper to check cl::opt and OptLevel (authored by rampitec).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105517/new/
https://reviews.llvm.org/D105517
Files:
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -785,6 +785,19 @@
bool addGCPasses() override;
std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
+
+ /// Check if a pass is enabled given \p Opt option. The option always
+ /// overrides defaults if explicitely used. Otherwise its default will
+ /// be used given that a pass shall work at an optimization \p Level
+ /// minimum.
+ bool isPassEnabled(const cl::opt<bool> &Opt,
+ CodeGenOpt::Level Level = CodeGenOpt::Default) const {
+ if (Opt.getNumOccurrences())
+ return Opt;
+ if (TM->getOptLevel() < Level)
+ return false;
+ return Opt;
+ }
};
std::unique_ptr<CSEConfigBase> AMDGPUPassConfig::getCSEConfig() const {
@@ -928,9 +941,7 @@
if (EnableSROA)
addPass(createSROAPass());
- if (EnableScalarIRPasses.getNumOccurrences()
- ? EnableScalarIRPasses
- : TM.getOptLevel() > CodeGenOpt::Less)
+ if (isPassEnabled(EnableScalarIRPasses))
addStraightLineScalarOptimizationPasses();
if (EnableAMDGPUAliasAnalysis) {
@@ -962,9 +973,7 @@
// %1 = shl %a, 2
//
// but EarlyCSE can do neither of them.
- if (EnableScalarIRPasses.getNumOccurrences()
- ? EnableScalarIRPasses
- : TM.getOptLevel() > CodeGenOpt::Less)
+ if (isPassEnabled(EnableScalarIRPasses))
addEarlyCSEOrGVNPass();
}
@@ -980,9 +989,7 @@
TargetPassConfig::addCodeGenPrepare();
- if (EnableLoadStoreVectorizer.getNumOccurrences()
- ? EnableLoadStoreVectorizer
- : TM->getOptLevel() > CodeGenOpt::Less)
+ if (isPassEnabled(EnableLoadStoreVectorizer))
addPass(createLoadStoreVectorizerPass());
// LowerSwitch pass may introduce unreachable blocks that can
@@ -1107,9 +1114,7 @@
if (EnableDPPCombine)
addPass(&GCNDPPCombineID);
addPass(&SILoadStoreOptimizerID);
- if (EnableSDWAPeephole.getNumOccurrences()
- ? EnableSDWAPeephole
- : TM->getOptLevel() > CodeGenOpt::Less) {
+ if (isPassEnabled(EnableSDWAPeephole)) {
addPass(&SIPeepholeSDWAID);
addPass(&EarlyMachineLICMID);
addPass(&MachineCSEID);
@@ -1200,9 +1205,7 @@
if (OptExecMaskPreRA)
insertPass(&MachineSchedulerID, &SIOptimizeExecMaskingPreRAID);
- if (EnablePreRAOptimizations.getNumOccurrences()
- ? EnablePreRAOptimizations
- : TM->getOptLevel() > CodeGenOpt::Less)
+ if (isPassEnabled(EnablePreRAOptimizations))
insertPass(&RenameIndependentSubregsID, &GCNPreRAOptimizationsID);
// This is not an essential optimization and it has a noticeable impact on
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105517.356865.patch
Type: text/x-patch
Size: 2789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210707/5513682f/attachment-0001.bin>
More information about the llvm-commits
mailing list