|
LLVM
4.0.0
|
Fix bitcasted functions. More...
#include "WebAssembly.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"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 Function * | CreateWrapper (Function *F, FunctionType *Ty) |
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.
| #define DEBUG_TYPE "wasm-fix-function-bitcasts" |
Definition at line 36 of file WebAssemblyFixFunctionBitcasts.cpp.
|
static |
Definition at line 90 of file WebAssemblyFixFunctionBitcasts.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), AMDGPU::RuntimeMD::KeyName::Args, llvm::Call, llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), llvm::Function::eraseFromParent(), llvm::UndefValue::get(), llvm::Module::getContext(), llvm::Function::getFunctionType(), llvm::GlobalValue::getParent(), llvm::FunctionType::getReturnType(), llvm::Type::isVoidTy(), llvm::FunctionType::param_begin(), llvm::FunctionType::param_end(), llvm::GlobalValue::PrivateLinkage, and llvm::ARMISD::Wrapper.
|
static |
Definition at line 64 of file WebAssemblyFixFunctionBitcasts.cpp.
References llvm::GlobalValue::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::Value::uses().
1.8.6