27 #define DEBUG_TYPE "amdgpu-annotate-uniform" 44 AMDGPUAnnotateUniformValues() :
46 bool doInitialization(
Module &M)
override;
49 return "AMDGPU Annotate Uniform Values";
66 "Add AMDGPU uniform metadata",
false,
false)
73 char AMDGPUAnnotateUniformValues::
ID = 0;
76 I->setMetadata(
"amdgpu.uniform",
MDNode::get(
I->getContext(), {}));
88 bool AMDGPUAnnotateUniformValues::isClobberedInFunction(
LoadInst *
Load) {
97 const Loop *L = LI->getLoopFor(Start);
108 DFS(Start, Checklist);
109 for (
auto &BB : Checklist) {
114 if (Q.isClobber() || Q.isUnknown())
120 void AMDGPUAnnotateUniformValues::visitBranchInst(
BranchInst &
I) {
125 if (!DA->isUniform(Cond))
131 void AMDGPUAnnotateUniformValues::visitLoadInst(
LoadInst &I) {
133 if (!DA->isUniform(Ptr))
142 bool NotClobbered = isKernelFunc && !isClobberedInFunction(&I);
144 if (!PtrI && NotClobbered && isGlobalLoad(I)) {
145 if (isa<Argument>(Ptr) || isa<GlobalValue>(Ptr)) {
147 if (noClobberClones.count(Ptr)) {
148 PtrI = noClobberClones[Ptr];
170 bool AMDGPUAnnotateUniformValues::doInitialization(
Module &M) {
179 DA = &getAnalysis<DivergenceAnalysis>();
180 MDR = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
181 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
185 noClobberClones.clear();
191 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.
Compute iterated dominance frontiers using a linear time algorithm.
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)
AMDGPUAS getAMDGPUAS(const Module &M)
LLVMContext & getContext() const
All values hold a context through their type.
An instruction for reading from memory.
Value * getCondition() const
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Type * getPointerElementType() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
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()
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.
Calling convention for AMDGPU code object kernels.
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
bool isUnconditional() 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.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
block_iterator block_begin() const
const BasicBlock * getParent() const