19#include "llvm/IR/IntrinsicsSPIRV.h"
27#define DEBUG_TYPE "spirv-lower-resource-names"
37 if (AI && !Seen.
insert(AI).second)
40 Allocas[CI->getFunction()].push_back(AI);
53 switch (
F.getIntrinsicID()) {
54 case Intrinsic::spv_resource_handlefrombinding:
55 case Intrinsic::spv_resource_handlefromimplicitbinding:
56 for (
User *U :
F.users()) {
65 if (Intrinsics.
empty())
74 F->getIntrinsicID() == Intrinsic::spv_resource_handlefrombinding
75 ? Intrinsic::spv_resource_handlefrombinding_mdname
76 : Intrinsic::spv_resource_handlefromimplicitbinding_mdname;
79 Value *NamePtr = CI->getArgOperand(4);
88 CI->setCalledFunction(MdFn);
90 CI->setAttributes(CI->getAttributes().removeParamAttributes(Ctx, 4));
93 GV->removeDeadConstantUsers();
94 if (GV->hasLocalLinkage() && GV->use_empty())
95 GV->eraseFromParent();
107class SPIRVLowerResourceNamesLegacy :
public ModulePass {
110 SPIRVLowerResourceNamesLegacy() :
ModulePass(ID) {}
113char SPIRVLowerResourceNamesLegacy::ID = 0;
117 "SPIRV Lower Resource Names",
false,
false)
120 return new SPIRVLowerResourceNamesLegacy();
Hexagon Lower HLX Pair Allocas
Module.h This file contains the declarations for the Module class.
This file implements a map that provides insertion order iteration.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void promoteNameAllocas(ArrayRef< CallInst * > Intrinsics)
static bool lowerResourceNames(Module &M)
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents a function call, abstracting a target machine's calling convention.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
This class implements a map that also provides access to all stored values in a deterministic order.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
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.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
LLVM Value Representation.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createSPIRVLowerResourceNamesLegacyPass()
LLVM_ABI void PromoteMemToReg(ArrayRef< AllocaInst * > Allocas, DominatorTree &DT, AssumptionCache *AC=nullptr)
Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appro...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
LLVM_ABI bool isAllocaPromotable(const AllocaInst *AI)
Return true if this alloca is legal for promotion.
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth, bool MustPreserveProvenance=false)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.