LLVM  6.0.0svn
Macros | Functions | Variables
WebAssemblyFixFunctionBitcasts.cpp File Reference

Fix bitcasted functions. More...

#include "WebAssembly.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Include dependency graph for WebAssemblyFixFunctionBitcasts.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "wasm-fix-function-bitcasts"
 

Functions

static void FindUses (Value *V, Function &F, SmallVectorImpl< std::pair< Use *, Function *>> &Uses, SmallPtrSetImpl< Constant *> &ConstantBCs)
 
static FunctionCreateWrapper (Function *F, FunctionType *Ty)
 

Variables

static cl::opt< boolTemporaryWorkarounds ("wasm-temporary-workarounds", cl::desc("Apply certain temporary workarounds"), cl::init(true), cl::Hidden)
 

Detailed Description

Fix bitcasted functions.

WebAssembly requires caller and callee signatures to match, however in LLVM, some amount of slop is vaguely permitted. Detect mismatch by looking for bitcasts of functions and rewrite them to use wrapper functions instead.

This doesn't catch all cases, such as when a function's address is taken in one place and casted in another, but it works for many common cases.

Note that LLVM already optimizes away function bitcasts in common cases by dropping arguments as needed, so this pass only ends up getting used in less common cases.

Definition in file WebAssemblyFixFunctionBitcasts.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "wasm-fix-function-bitcasts"

Definition at line 37 of file WebAssemblyFixFunctionBitcasts.cpp.

Function Documentation

◆ CreateWrapper()

static Function* CreateWrapper ( Function F,
FunctionType Ty 
)
static

◆ FindUses()

static void FindUses ( Value V,
Function F,
SmallVectorImpl< std::pair< Use *, Function *>> &  Uses,
SmallPtrSetImpl< Constant *> &  ConstantBCs 
)
static

Variable Documentation

◆ TemporaryWorkarounds

cl::opt<bool> TemporaryWorkarounds("wasm-temporary-workarounds", cl::desc("Apply certain temporary workarounds"), cl::init(true), cl::Hidden)
static

Referenced by CreateWrapper().