27#define DEBUG_TYPE "wasm-ref-type-mem2local"
30class WebAssemblyRefTypeMem2LocalImpl
31 :
public InstVisitor<WebAssemblyRefTypeMem2LocalImpl> {
39class WebAssemblyRefTypeMem2LocalLegacy final :
public FunctionPass {
41 return "WebAssembly Reference Types Memory to Local";
57char WebAssemblyRefTypeMem2LocalLegacy::ID = 0;
59 "Assign reference type allocas to local address space",
true,
63 return new WebAssemblyRefTypeMem2LocalLegacy();
66void WebAssemblyRefTypeMem2LocalImpl::visitAllocaInst(
AllocaInst &AI) {
70 IRB.SetInsertPoint(&AI);
72 WebAssembly::WASM_ADDRESS_SPACE_VAR,
nullptr,
93bool WebAssemblyRefTypeMem2LocalImpl::runOnFunction(Function &
F) {
94 LLVM_DEBUG(
dbgs() <<
"********** WebAssembly RefType Mem2Local **********\n"
95 "********** Function: "
96 <<
F.getName() <<
'\n');
98 if (
F.getFnAttribute(
"target-features")
100 .contains(
"+reference-types"))
105bool WebAssemblyRefTypeMem2LocalLegacy::runOnFunction(Function &
F) {
106 WebAssemblyRefTypeMem2LocalImpl Impl;
107 return Impl.runOnFunction(
F);
113 WebAssemblyRefTypeMem2LocalImpl Impl;
114 return Impl.runOnFunction(
F)
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
FunctionAnalysisManager FAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
an instruction to allocate memory on the stack
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
Base class for instruction visitors.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Represent a constant reference to a string, i.e.
static LLVM_ABI void ValueIsRAUWd(Value *Old, Value *New)
LLVMContext & getContext() const
All values hold a context through their type.
bool materialized_use_empty() const
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
use_iterator materialized_use_begin()
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyRefTypeMem2LocalLegacyPass()
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.