summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-01-29 00:30:46 +0000
committerSam Clegg <sbc@chromium.org>2019-01-29 00:30:46 +0000
commitb54927cc48920083c0b19586d04b6dffc9de0aa4 (patch)
tree14c74a13c7b54b8abdaa3e21df0348ef25183b36 /llvm/test/CodeGen
parent85e72c3d56c7abbb1e1d4dc22d8565ff36bed919 (diff)
downloadbcm5719-llvm-b54927cc48920083c0b19586d04b6dffc9de0aa4.tar.gz
bcm5719-llvm-b54927cc48920083c0b19586d04b6dffc9de0aa4.zip
[WebAssembly] Handle more types of uses in WebAssemblyAddMissingPrototypes
Previously we were only handling bitcast operations, however prototypeless functions can also appear in other places such as comparisons and as function params. Switch to using replaceAllUsesWith() to replace the prototype-less function uses. This new approach results in some redundant bitcasting but is much simpler and handles all cases. Differential Revision: https://reviews.llvm.org/D56938 llvm-svn: 352445
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/WebAssembly/add-prototypes.ll29
1 files changed, 25 insertions, 4 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/add-prototypes.ll b/llvm/test/CodeGen/WebAssembly/add-prototypes.ll
index 583cadea03b..865b3d3f3b3 100644
--- a/llvm/test/CodeGen/WebAssembly/add-prototypes.ll
+++ b/llvm/test/CodeGen/WebAssembly/add-prototypes.ll
@@ -17,7 +17,8 @@ define void @call_foo(i32 %a) {
}
; CHECK-LABEL: @call_foo_ptr
-; CHECK: %call = call i64 @foo(i32 43)
+; CHECK: %1 = bitcast i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*) to i64 (i32)*
+; CHECK-NEXT: %call = call i64 %1(i32 43)
define i64 @call_foo_ptr(i32 %a) {
%1 = bitcast i64 (...)* @foo to i64 (i32)*
%call = call i64 (i32) %1(i32 43)
@@ -25,7 +26,8 @@ define i64 @call_foo_ptr(i32 %a) {
}
; CHECK-LABEL: @to_intptr_inst
-; CHECK: ret i8* bitcast (i64 (i32)* @foo to i8*)
+; CHECK: %1 = bitcast i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*) to i8*
+; CHECK-NEXT: ret i8* %1
define i8* @to_intptr_inst() {
%1 = bitcast i64 (...)* @foo to i8*
ret i8* %1
@@ -37,8 +39,27 @@ define i8* @to_intptr_constexpr() {
ret i8* bitcast (i64 (...)* @foo to i8*)
}
-; CHECK: declare i64 @foo(i32)
-declare i64 @foo(...) #1
+; CHECK-LABEL: @null_compare
+; CHECK: br i1 icmp eq (i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*), i64 (...)* null), label %if.then, label %if.end
+define i8 @null_compare() {
+ br i1 icmp eq (i64 (...)* @foo, i64 (...)* null), label %if.then, label %if.end
+if.then:
+ ret i8 0
+if.end:
+ ret i8 1
+}
+
+; CHECK-LABEL: @as_paramater
+; CHECK: call void @func_param(i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*))
+define void @as_paramater() {
+ call void @func_param(i64 (...)* @foo)
+ ret void
+}
+
+declare void @func_param(i64 (...)*)
+
+; CHECK: declare extern_weak i64 @foo(i32)
+declare extern_weak i64 @foo(...) #1
; CHECK-NOT: attributes {{.*}} = { {{.*}}"no-prototype"{{.*}} }
attributes #1 = { "no-prototype" }
OpenPOWER on IntegriCloud