Skip to content

Commit

Permalink
[WebAssembly] Convert some tests to opaque pointers (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Dec 19, 2022
1 parent b006b60 commit 7385624
Show file tree
Hide file tree
Showing 109 changed files with 3,481 additions and 3,557 deletions.
7 changes: 3 additions & 4 deletions llvm/test/CodeGen/WebAssembly/PR40172.ll
Expand Up @@ -20,11 +20,10 @@ define void @test(i8 %byte) {
%x5 = icmp eq i8 %x4, 1
%x6 = and i8 %byte, 2
%x7 = icmp eq i8 %x6, 2
%x8 = bitcast { i8, i8 }* %t to i8*
%x9 = zext i1 %x5 to i8
store i8 %x9, i8* %x8, align 1
%x10 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %t, i32 0, i32 1
store i8 %x9, ptr %t, align 1
%x10 = getelementptr inbounds { i8, i8 }, ptr %t, i32 0, i32 1
%x11 = zext i1 %x7 to i8
store i8 %x11, i8* %x10, align 1
store i8 %x11, ptr %x10, align 1
ret void
}
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/WebAssembly/PR40267.ll
Expand Up @@ -8,14 +8,14 @@
target triple = "wasm32-unknown-unknown"

define void @foo() {
%L6 = load i32, i32* undef
%L6 = load i32, ptr undef
br label %BB1

BB1: ; preds = %BB1, %0
%bj = select <4 x i1> <i1 true, i1 true, i1 false, i1 false>, <4 x i32> <i32 55, i32 21, i32 92, i32 68>, <4 x i32> <i32 51, i32 61, i32 62, i32 39>
%E1 = extractelement <4 x i32> %bj, i32 0
%E23 = extractelement <4 x i32> zeroinitializer, i32 %E1
%I33 = insertelement <4 x i32> undef, i32 %E23, i1 undef
store <4 x i32> %I33, <4 x i32>* undef
store <4 x i32> %I33, ptr undef
br label %BB1
}
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/WebAssembly/PR41149.ll
Expand Up @@ -22,10 +22,10 @@ define void @mod() {
; CHECK-NEXT: i32.sub
; CHECK-NEXT: i32.store8 0
; CHECK-NEXT: # fallthrough-return
%tmp = load <4 x i8>, <4 x i8>* undef
%tmp = load <4 x i8>, ptr undef
%tmp2 = icmp slt <4 x i8> %tmp, zeroinitializer
%tmp3 = sub <4 x i8> zeroinitializer, %tmp
%tmp4 = select <4 x i1> %tmp2, <4 x i8> %tmp3, <4 x i8> %tmp
store <4 x i8> %tmp4, <4 x i8>* undef
store <4 x i8> %tmp4, ptr undef
ret void
}
46 changes: 21 additions & 25 deletions llvm/test/CodeGen/WebAssembly/add-prototypes.ll
Expand Up @@ -3,71 +3,67 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"

; CHECK: @foo_addr = global i64 (i32)* @foo, align 8
@foo_addr = global i64 (i32)* bitcast (i64 (...)* @foo to i64 (i32)*), align 8
; CHECK: @foo_addr = global ptr @foo, align 8
@foo_addr = global ptr @foo, align 8

; CHECK: @foo_addr_i8 = global i8* bitcast (i64 (i32)* @foo to i8*), align 8
@foo_addr_i8 = global i8* bitcast (i64 (...)* @foo to i8*), align 8
; CHECK: @foo_addr_i8 = global ptr @foo, align 8
@foo_addr_i8 = global ptr @foo, align 8

; CHECK-LABEL: @call_foo
; CHECK: %call = call i64 @foo(i32 42)
define void @call_foo(i32 %a) {
%call = call i64 bitcast (i64 (...)* @foo to i64 (i32)*)(i32 42)
%call = call i64 @foo(i32 42)
ret void
}

; CHECK-LABEL: @call_foo_ptr
; CHECK: %1 = bitcast i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*) to i64 (i32)*
; CHECK-NEXT: %call = call i64 %1(i32 43)
; CHECK-NEXT: %call = call i64 @foo(i32 43)
define i64 @call_foo_ptr(i32 %a) {
%1 = bitcast i64 (...)* @foo to i64 (i32)*
%call = call i64 (i32) %1(i32 43)
%call = call i64 (i32) @foo(i32 43)
ret i64 %call
}

; CHECK-LABEL: @to_intptr_inst
; 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
; CHECK-NEXT: ret ptr @foo
define ptr @to_intptr_inst() {
ret ptr @foo
}

; CHECK-LABEL: @to_intptr_constexpr
; CHECK: ret i8* bitcast (i64 (i32)* @foo to i8*)
define i8* @to_intptr_constexpr() {
ret i8* bitcast (i64 (...)* @foo to i8*)
; CHECK: ret ptr @foo
define ptr @to_intptr_constexpr() {
ret ptr @foo
}

; CHECK-LABEL: @null_compare
; CHECK: br i1 icmp eq (i64 (...)* bitcast (i64 (i32)* @foo to i64 (...)*), i64 (...)* null), label %if.then, label %if.end
; CHECK: br i1 icmp eq (ptr @foo, ptr 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
br i1 icmp eq (ptr @foo, ptr 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 (...)*))
; CHECK: call void @func_param(ptr @foo)
define void @as_paramater() {
call void @func_param(i64 (...)* @foo)
call void @func_param(ptr @foo)
ret void
}

; Check if a sret parameter works in a no-prototype function.
; CHECK-LABEL: @sret_param
; CHECK: call void @make_struct_foo(%struct.foo* sret(%struct.foo) %foo)
; CHECK: call void @make_struct_foo(ptr sret(%struct.foo) %foo)
%struct.foo = type { i32, i32 }
declare void @make_struct_foo(%struct.foo* sret(%struct.foo), ...) #1
declare void @make_struct_foo(ptr sret(%struct.foo), ...) #1
define void @sret_param() {
%foo = alloca %struct.foo, align 4
call void bitcast (void (%struct.foo*, ...)* @make_struct_foo to void (%struct.foo*)*)(%struct.foo* sret(%struct.foo) %foo)
call void @make_struct_foo(ptr sret(%struct.foo) %foo)
ret void
}

declare void @func_param(i64 (...)*)
declare void @func_param(ptr)

; CHECK: declare void @func_not_called()
declare void @func_not_called(...) #1
Expand Down

0 comments on commit 7385624

Please sign in to comment.