36 #define DEBUG_TYPE "wasm-fix-function-bitcasts"
39 class FixFunctionBitcasts final :
public ModulePass {
41 return "WebAssembly Fix Function Bitcasts";
49 bool runOnModule(
Module &M)
override;
59 return new FixFunctionBitcasts();
70 else if (U.get()->getType() != F.
getType()) {
71 if (isa<Constant>(U.get())) {
73 auto c = ConstantBCs.
insert(cast<Constant>(U.get()));
74 if (!c.second)
continue;
76 Uses.push_back(std::make_pair(&U, &F));
102 for (; AI != Wrapper->
arg_end() && PI != PE; ++AI, ++PI) {
103 if (AI->getType() != *PI) {
107 Args.push_back(&*AI);
109 for (; PI != PE; ++PI)
130 bool FixFunctionBitcasts::runOnModule(
Module &M) {
139 for (
auto &UseFunc : Uses) {
140 Use *U = UseFunc.first;
151 auto Pair = Wrappers.
insert(std::make_pair(std::make_pair(F, Ty),
nullptr));
159 if (isa<Constant>(U->get()))
iterator_range< use_iterator > uses()
ModulePass * createWebAssemblyFixFunctionBitcasts()
A Module instance is used to store all the information related to an LLVM module. ...
Type::subtype_iterator param_iterator
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This class represents a function call, abstracting a target machine's calling convention.
Like Internal, but omit from symbol table.
Type * getElementType() const
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
A Use represents the edge between a Value definition and its users.
param_iterator param_end() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Class to represent function types.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Class to represent pointers.
static Function * CreateWrapper(Function *F, FunctionType *Ty)
LLVM Basic Block Representation.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
param_iterator param_begin() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Represent the analysis usage information of a pass.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
PointerType * getType() const
Global values are always pointers.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getReturnType() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static void FindUses(Value *V, Function &F, SmallVectorImpl< std::pair< Use *, Function * >> &Uses, SmallPtrSetImpl< Constant * > &ConstantBCs)
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
LLVMContext & getContext() const
Get the global data context.
bool isVoidTy() const
Return true if this is 'void'.