LLVM: lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
23
24#define DEBUG_TYPE "amdgpu-annotate-uniform"
25
26using namespace llvm;
27
28namespace {
29
30class AMDGPUAnnotateUniformValues
31 : public InstVisitor {
35 bool isEntryFunc;
36 bool Changed = false;
37
39 I->setMetadata("amdgpu.uniform", MDNode::get(I->getContext(), {}));
40 Changed = true;
41 }
42
44 I->setMetadata("amdgpu.noclobber", MDNode::get(I->getContext(), {}));
45 Changed = true;
46 }
47
48public:
51 : UA(&UA), MSSA(&MSSA), AA(&AA),
53
56
57 bool changed() const { return Changed; }
58};
59
60}
61
62void AMDGPUAnnotateUniformValues::visitBranchInst(BranchInst &I) {
63 if (UA->isUniform(&I))
64 setUniformMetadata(&I);
65}
66
67void AMDGPUAnnotateUniformValues::visitLoadInst(LoadInst &I) {
68 Value *Ptr = I.getPointerOperand();
69 if (!UA->isUniform(Ptr))
70 return;
72 if (PtrI)
73 setUniformMetadata(PtrI);
74
75
76
77
78 if (!isEntryFunc)
79 return;
82 setNoClobberMetadata(&I);
83}
84
91
92 AMDGPUAnnotateUniformValues Impl(UI, MSSA, AA, F);
93 Impl.visit(F);
94
95 if (!Impl.changed())
97
99
101 return PA;
102}
103
105public:
107
109
111
114 return "AMDGPU Annotate Uniform Values";
115 }
116
122 }
123};
124
126 if (skipFunction(F))
127 return false;
128
130 getAnalysis().getUniformityInfo();
131 MemorySSA &MSSA = getAnalysis().getMSSA();
132 AliasAnalysis &AA = getAnalysis().getAAResults();
133
134 AMDGPUAnnotateUniformValues Impl(UI, MSSA, AA, F);
135 Impl.visit(F);
136 return Impl.changed();
137}
138
140 "Add AMDGPU uniform metadata", false, false)
146
148
151}
Add AMDGPU uniform metadata
static bool runOnFunction(Function &F, bool PostInlining)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
LLVM IR instance of the generic uniformity analysis.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
AMDGPUAnnotateUniformValuesLegacy()
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Conditional or Unconditional Branch instruction.
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
Base class for instruction visitors.
RetTy visitBranchInst(BranchInst &I)
RetTy visitLoadInst(LoadInst &I)
An instruction for reading from memory.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
An analysis that produces MemorySSA for a function.
Legacy analysis pass which computes MemorySSA.
Encapsulates MemorySSA, including all data associated with memory accesses.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void preserveSet()
Mark an analysis set as preserved.
StringRef - Represent a constant reference to a string, i.e.
Analysis pass which computes UniformityInfo.
Legacy analysis pass which computes a CycleInfo.
LLVM Value Representation.
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
bool isEntryFunctionCC(CallingConv::ID CC)
bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, AAResults *AA)
Check is a Load is clobbered in its function.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createAMDGPUAnnotateUniformValuesLegacy()
T uniform(GenT &Gen, T Min, T Max)
Return a uniformly distributed random value between Min and Max.