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) {
175 bool AMDGPUAnnotateUniformValues::runOnFunction(
Function &F) {
179 DA = &getAnalysis<DivergenceAnalysis>();
180 MDR = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
181 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
185 noClobberClones.clear();
191 return new AMDGPUAnnotateUniformValues();
const_iterator end(StringRef path)
Get end iterator over path.
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. ...
AMDGPUAS getAMDGPUAS(const Module &M)
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...
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
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.
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.
InstListType::iterator iterator
Instruction iterators...
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.
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 TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Calling convention for AMDGPU code object kernels.
const BasicBlock * getParent() const