[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 16:16:03 PDT 2021
rampitec created this revision.
rampitec added reviewers: arsenm, bsaleil.
Herald added subscribers: foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
rampitec requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
We have several checks for both cl::opt and OptLevel over our
pass config, although these checks do not properly work if
default value of a cl::opt will be false. Create a helper to
use instead and properly handle it. NFC for now.
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,15 @@
bool addGCPasses() override;
std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
+
+ 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 +937,7 @@
if (EnableSROA)
addPass(createSROAPass());
- if (EnableScalarIRPasses.getNumOccurrences()
- ? EnableScalarIRPasses
- : TM.getOptLevel() > CodeGenOpt::Less)
+ if (isPassEnabled(EnableScalarIRPasses))
addStraightLineScalarOptimizationPasses();
if (EnableAMDGPUAliasAnalysis) {
@@ -962,9 +969,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 +985,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 +1110,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 +1201,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.356832.patch
Type: text/x-patch
Size: 2554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210706/44ba8cf5/attachment-0001.bin>
More information about the llvm-commits
mailing list