27 #define DEBUG_TYPE "amdgpu-annotate-uniform" 43 AMDGPUAnnotateUniformValues() :
45 bool doInitialization(
Module &M)
override;
48 return "AMDGPU Annotate Uniform Values";
65 "Add AMDGPU uniform metadata",
false,
false)
72 char AMDGPUAnnotateUniformValues::
ID = 0;
75 I->setMetadata(
"amdgpu.uniform",
MDNode::get(
I->getContext(), {}));
87 bool AMDGPUAnnotateUniformValues::isClobberedInFunction(
LoadInst *
Load) {
96 const Loop *L = LI->getLoopFor(Start);
107 DFS(Start, Checklist);
108 for (
auto &BB : Checklist) {
113 if (Q.isClobber() || Q.isUnknown())
119 void AMDGPUAnnotateUniformValues::visitBranchInst(
BranchInst &
I) {
120 if (DA->isUniform(&I))
124 void AMDGPUAnnotateUniformValues::visitLoadInst(
LoadInst &I) {
126 if (!DA->isUniform(Ptr))
135 bool NotClobbered = isKernelFunc && !isClobberedInFunction(&I);
137 if (!PtrI && NotClobbered && isGlobalLoad(I)) {
138 if (isa<Argument>(Ptr) || isa<GlobalValue>(Ptr)) {
140 if (noClobberClones.count(Ptr)) {
141 PtrI = noClobberClones[Ptr];
163 bool AMDGPUAnnotateUniformValues::doInitialization(
Module &M) {
171 DA = &getAnalysis<LegacyDivergenceAnalysis>();
172 MDR = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
173 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
177 noClobberClones.clear();
183 return new AMDGPUAnnotateUniformValues();
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
Base class for instruction visitors.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
LLVMContext & getContext() const
All values hold a context through their type.
An instruction for reading from memory.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Type * getPointerElementType() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
T uniform(GenT &Gen, T Min, T Max)
Return a uniformly distributed random value between Min and Max.
BlockT * getHeader() const
Type * getType() const
All values are typed, get the type of this value.
bool insert(const value_type &X)
Insert a new element into the SetVector.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
const BasicBlock & getEntryBlock() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
static bool runOnFunction(Function &F, bool PostInlining)
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Value * getPointerOperand()
Address space for global memory (RAT0, VTX0).
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
FunctionPass * createAMDGPUAnnotateUniformValues()
static Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Representation for a specific memory location.
Iterator for intrusive lists based on ilist_node.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
pred_range predecessors(BasicBlock *BB)
Class for arbitrary precision integers.
Interface for the AMDGPU Implementation of the Intrinsic Info class.
void setPreservesAll()
Set by analyses that do not transform their input at all.
InstListType::iterator iterator
Instruction iterators...
LoopT * getParentLoop() const
static IntegerType * getInt32Ty(LLVMContext &C)
Represents a single loop in the control flow graph.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
block_iterator block_end() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
LLVM Value Representation.
A vector that has set insertion semantics.
The legacy pass manager's analysis pass to compute loop information.
StringRef - Represent a constant reference to a string, i.e.
block_iterator block_begin() const
Calling convention for AMDGPU code object kernels.
const BasicBlock * getParent() const