diff options
author | Dan Gohman <dan433584@gmail.com> | 2017-01-07 00:34:54 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2017-01-07 00:34:54 +0000 |
commit | 1b637458f6de8fdae53bd54ed6b9bede000c332c (patch) | |
tree | b7768878809f4c10b8dae72d311192b40c8bb348 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | 1d3577537992b862fb9c70f9adc1ad1a4cb09766 (diff) | |
download | llvm-1b637458f6de8fdae53bd54ed6b9bede000c332c.zip llvm-1b637458f6de8fdae53bd54ed6b9bede000c332c.tar.gz llvm-1b637458f6de8fdae53bd54ed6b9bede000c332c.tar.bz2 |
[WebAssembly] Add a pass to create wrappers for function bitcasts.
WebAssembly requires caller and callee signatures to match exactly. In LLVM,
there are a variety of circumstances where signatures may be mismatched in
practice, and one can bitcast a function address to another type to call it
as that type. This patch adds a pass which replaces bitcasted function
addresses with wrappers to replace the bitcasts.
This doesn't catch everything, but it does match many common cases.
llvm-svn: 291315
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index b61bc0a..f5ef35a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -163,6 +163,10 @@ void WebAssemblyPassConfig::addIRPasses() { // control specifically what gets lowered. addPass(createAtomicExpandPass(TM)); + // Fix function bitcasts, as WebAssembly requires caller and callee signatures + // to match. + addPass(createWebAssemblyFixFunctionBitcasts()); + // Optimize "returned" function attributes. if (getOptLevel() != CodeGenOpt::None) addPass(createWebAssemblyOptimizeReturned()); |