aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-01-07 00:34:54 +0000
committerDan Gohman <dan433584@gmail.com>2017-01-07 00:34:54 +0000
commit1b637458f6de8fdae53bd54ed6b9bede000c332c (patch)
treeb7768878809f4c10b8dae72d311192b40c8bb348 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parent1d3577537992b862fb9c70f9adc1ad1a4cb09766 (diff)
downloadllvm-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.cpp4
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());