21#define DEBUG_TYPE "spirv-prepare-globals"
27struct SPIRVPrepareGlobals :
public ModulePass {
32 return "SPIRV prepare global variables";
35 bool runOnModule(
Module &M)
override;
42 if (AT->getNumElements() != 0)
47 Bitcode.replaceInitializer(OneEltInit);
60 constexpr unsigned WorkgroupAS =
62 const bool IsWorkgroupExternal =
64 if (!IsWorkgroupExternal)
68 if (!AT || AT->getNumElements() != 0)
71 constexpr auto UInt32Max = std::numeric_limits<uint32_t>::max();
97 LLVM_DEBUG(
dbgs() <<
"Skipping alias whose aliasee is not a GlobalObject: "
102 if (AO->isInterposable()) {
103 LLVM_DEBUG(
dbgs() <<
"Skipping interposable aliasee: " << AO->getName()
109 <<
" with aliasee: " << AO->getName() <<
"\n");
119bool SPIRVPrepareGlobals::runOnModule(
Module &M) {
123 Changed |= tryReplaceAliasWithAliasee(GA);
126 const bool IsAMD = M.getTargetTriple().getVendor() ==
Triple::AMD;
134 Changed |= tryExtendDynamicLDSGlobal(GV);
138char SPIRVPrepareGlobals::ID = 0;
143 "SPIRV prepare global variables",
false,
false)
147 return new SPIRVPrepareGlobals();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
const Constant * getAliasee() const
bool hasExternalLinkage() const
LinkageTypes getLinkage() const
ThreadLocalMode getThreadLocalMode() const
unsigned getAddressSpace() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit.
Type * getValueType() const
bool isExternallyInitialized() const
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LLVM_ABI void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
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.
StringRef - Represent a constant reference to a string, i.e.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
constexpr unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
ModulePass * createSPIRVPrepareGlobalsPass()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.