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) {
112 true, StartIt, BB, Load).isClobber())
118 void AMDGPUAnnotateUniformValues::visitBranchInst(
BranchInst &
I) {
123 if (!DA->isUniform(Cond))
129 void AMDGPUAnnotateUniformValues::visitLoadInst(
LoadInst &I) {
131 if (!DA->isUniform(Ptr))
140 bool NotClobbered = isKernelFunc && !isClobberedInFunction(&I);
142 if (!PtrI && NotClobbered && isGlobalLoad(I)) {
143 if (isa<Argument>(Ptr) || isa<GlobalValue>(
Ptr)) {
145 if (noClobberClones.count(Ptr)) {
146 PtrI = noClobberClones[
Ptr];
168 bool AMDGPUAnnotateUniformValues::doInitialization(
Module &M) {
172 bool AMDGPUAnnotateUniformValues::runOnFunction(
Function &F) {
176 DA = &getAnalysis<DivergenceAnalysis>();
177 MDR = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
178 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
182 noClobberClones.clear();
188 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.
A Module instance is used to store all the information related to an LLVM module. ...
LoopT * getParentLoop() const
const Function * getParent() const
Return the enclosing method, or null if none.
An instruction for reading from memory.
BlockT * getHeader() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Type * getPointerElementType() const
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isUnconditional() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
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.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
Calling convention for AMDGPU code object kernels.
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
Value * getPointerOperand()
LLVMContext & getContext() const
All values hold a context through their type.
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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.
Type * getType() const
All values are typed, get the type of this value.
pred_range predecessors(BasicBlock *BB)
const BasicBlock & getEntryBlock() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
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.
block_iterator block_end() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Value * getCondition() const
static IntegerType * getInt32Ty(LLVMContext &C)
Represents a single loop in the control flow graph.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
LLVM Value Representation.
A vector that has set insertion semantics.
block_iterator block_begin() const
The legacy pass manager's analysis pass to compute loop information.
StringRef - Represent a constant reference to a string, i.e.
const BasicBlock * getParent() const
Address space for global memory (RAT0, VTX0).