Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebAssembly] Relax signature checking for undefined functions that a…
…re not called directly When function signatures don't match and the undefined function is not called directly (i.e. only has its address taken) we don't issue a warning or create a runtime thunk for the undefined function. Instead in this case we simply use the defined version of the function. This is possible since checking signatures of dynamic calls happens at runtime so any invalid usage will still result in a runtime error. This is needed to allow C++ programs to link without generating warnings. Its not uncommon in C++ for vtables to be populated by function address whee the signature of the function is not known in the compilation unit. In this case clang declares the method as void(void) and relies on the vtable caller casting the data back to the correct signature. Fixes: https://bugs.llvm.org/show_bug.cgi?id=40412 Differential Revision: https://reviews.llvm.org/D62153 llvm-svn: 361678
- Loading branch information
Showing
7 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o | ||
; RUN: llc -filetype=obj %s -o %t.main.o | ||
; RUN: wasm-ld --fatal-warnings -o %t.wasm %t.ret32.o %t.main.o | ||
; RUN: wasm-ld --fatal-warnings -o %t.wasm %t.main.o %t.ret32.o | ||
|
||
target triple = "wasm32-unknown-unknown" | ||
|
||
; Function declartion with incorrect signature. | ||
declare dso_local void @ret32() | ||
|
||
; Simply taking the address of the function should *not* generate the | ||
; the signature mismatch warning. | ||
@ptr = dso_local global i8* bitcast (void ()* @ret32 to i8*), align 8 | ||
|
||
define hidden void @_start() local_unnamed_addr { | ||
%addr = load i32 ()*, i32 ()** bitcast (i8** @ptr to i32 ()**), align 8 | ||
call i32 %addr() | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters