Skip to content

Commit

Permalink
Make conditional discard flags available externally
Browse files Browse the repository at this point in the history
This is so that we can set/access these flags in other `.cpp` files.
  • Loading branch information
kuhar committed Jan 26, 2022
1 parent c20ba76 commit f002213
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions llvm/lib/Target/AMDGPU/AMDGPUConditionalDiscard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,25 @@
using namespace llvm;
using namespace llvm::AMDGPU;

namespace llvm {
namespace cl {

// Enable conditional discard transformations
static cl::opt<bool> EnableConditionalDiscardTransformations(
opt<bool> EnableConditionalDiscardTransformations(
"amdgpu-conditional-discard-transformations",
cl::desc("Enable conditional discard transformations"),
cl::init(false),
cl::Hidden);
desc("Enable conditional discard transformations"),
init(false),
Hidden);

// Enable conditional discard to demote transformations
static cl::opt<bool> EnableTransformDiscardToDemote(
opt<bool> EnableTransformDiscardToDemote(
"amdgpu-transform-discard-to-demote",
cl::desc("Enable transformation of optimized discards to demotes"),
cl::init(false),
cl::Hidden);
desc("Enable transformation of optimized discards to demotes"),
init(false),
Hidden);

} // namespace cl
} // namespace llvm

namespace {

Expand Down Expand Up @@ -227,12 +233,12 @@ bool AMDGPUConditionalDiscard::runOnFunction(Function &F) {
if (skipFunction(F))
return false;

if (!(EnableConditionalDiscardTransformations ||
if (!(cl::EnableConditionalDiscardTransformations ||
F.hasFnAttribute("amdgpu-conditional-discard-transformations")))
return false;

bool ConvertToDemote =
(EnableTransformDiscardToDemote ||
(cl::EnableTransformDiscardToDemote ||
F.hasFnAttribute("amdgpu-transform-discard-to-demote"));

LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
Expand Down

0 comments on commit f002213

Please sign in to comment.