[llvm] 68a534e - [WebAssembly] Convert test to opaque pointers (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 01:30:24 PST 2023


Author: Nikita Popov
Date: 2023-01-16T10:30:00+01:00
New Revision: 68a534e9bf69e7e5f081a515e05f1d3cb4c21761

URL: https://github.com/llvm/llvm-project/commit/68a534e9bf69e7e5f081a515e05f1d3cb4c21761
DIFF: https://github.com/llvm/llvm-project/commit/68a534e9bf69e7e5f081a515e05f1d3cb4c21761.diff

LOG: [WebAssembly] Convert test to opaque pointers (NFC)

This test was testing both typed and opaque pointers. Remove the
typed pointer check lines, and update the input IR to use opaque
pointers. Note that with opaque pointers, the "bitcast" is not
explicit, but rather just a mismatch in function type between
the call and the declaration.

Added: 
    

Modified: 
    llvm/test/CodeGen/WebAssembly/function-bitcasts.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/WebAssembly/function-bitcasts.ll b/llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
index b99a0a27df02..0553f61ef905 100644
--- a/llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
+++ b/llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
@@ -1,10 +1,7 @@
-; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions | FileCheck %s --check-prefixes=CHECK,TYPED
-; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions -opaque-pointers | FileCheck %s --check-prefixes=CHECK,OPAQUE
+; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions | FileCheck %s
 
 ; Test that function pointer casts are replaced with wrappers.
 
-; The TYPED and OPAQUE prefixes only 
diff er in function ordering.
-
 target triple = "wasm32-unknown-unknown"
 
 define void @has_i32_arg(i32) {
@@ -23,10 +20,8 @@ declare void @foo2()
 declare void @foo3()
 
 ; CHECK-LABEL: test:
-; TYPED:      call        .Lhas_i32_arg_bitcast.2{{$}}
-; TYPED-NEXT: call        .Lhas_i32_arg_bitcast.2{{$}}
-; OPAQUE:      call       .Lhas_i32_arg_bitcast{{$}}
-; OPAQUE-NEXT: call       .Lhas_i32_arg_bitcast{{$}}
+; CHECK:      call       .Lhas_i32_arg_bitcast{{$}}
+; CHECK-NEXT: call       .Lhas_i32_arg_bitcast{{$}}
 ; CHECK-NEXT: call        .Lhas_i32_ret_bitcast{{$}}
 ; CHECK-NEXT: call        $drop=, has_i32_ret
 ; CHECK-NEXT: i32.const   $push[[L0:[0-9]+]]=, 0
@@ -43,19 +38,16 @@ declare void @foo3()
 ; CHECK-NEXT: end_function
 define void @test() {
 entry:
-  call void bitcast (void (i32)* @has_i32_arg to void ()*)()
-  call void bitcast (void (i32)* @has_i32_arg to void ()*)()
-  call void bitcast (i32 ()* @has_i32_ret to void ()*)()
-  call i32 bitcast (i32 ()* @has_i32_ret to i32 ()*)()
-  call void bitcast (void ()* @foo0 to void (i32)*)(i32 0)
-  %p = bitcast void ()* @foo0 to void (i32)*
-  call void %p(i32 0)
-  %q = bitcast void ()* @foo0 to void (i32)*
-  call void %q(i32 0)
-  %r = bitcast void (i32)* %q to void ()*
-  call void %r()
-  %t = call i32 bitcast (void ()* @foo1 to i32 ()*)()
-  call void bitcast (void ()* @foo2 to void ()*)()
+  call void @has_i32_arg()
+  call void @has_i32_arg()
+  call void @has_i32_ret()
+  call i32 @has_i32_ret()
+  call void @foo0(i32 0)
+  call void @foo0(i32 0)
+  call void @foo0(i32 0)
+  call void @foo0()
+  %t = call i32 @foo1()
+  call void @foo2()
   call void @foo1()
   call void @foo3()
 
@@ -64,29 +56,26 @@ entry:
 
 ; Calling aliases should also generate a wrapper
 
- at alias_i32_arg = weak hidden alias void (i32), void (i32)* @has_i32_arg
+ at alias_i32_arg = weak hidden alias void (i32), ptr @has_i32_arg
 
 ; CHECK-LABEL: test_alias:
-; TYPED: call    .Lhas_i32_arg_bitcast.2
-; OPAQUE: call   .Lhas_i32_arg_bitcast
+; CHECK: call   .Lhas_i32_arg_bitcast
 define void @test_alias() {
 entry:
-  call void bitcast (void (i32)* @alias_i32_arg to void ()*)()
+  call void @alias_i32_arg()
   ret void
 }
 
 
 ; CHECK-LABEL: test_structs:
-; TYPED: call     .Lhas_i32_arg_bitcast.1, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
-; TYPED: call     .Lhas_i32_arg_bitcast, $0, $pop2
-; OPAQUE: call    .Lhas_i32_arg_bitcast.2, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
-; OPAQUE: call    .Lhas_i32_arg_bitcast.1, $0, $pop2
+; CHECK: call    .Lhas_i32_arg_bitcast.2, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
+; CHECK: call    .Lhas_i32_arg_bitcast.1, $0, $pop2
 ; CHECK: call     .Lhas_struct_arg_bitcast{{$}}
 define void @test_structs() {
 entry:
-  call void bitcast (void (i32)* @has_i32_arg to void (i32, {i32})*)(i32 5, {i32} {i32 6})
-  call {i32, i64} bitcast (void (i32)* @has_i32_arg to {i32, i64} (i32)*)(i32 7)
-  call void bitcast (void ({i32})* @has_struct_arg to void ()*)()
+  call void @has_i32_arg(i32 5, {i32} {i32 6})
+  call {i32, i64} @has_i32_arg(i32 7)
+  call void @has_struct_arg()
   ret void
 }
 
@@ -97,8 +86,8 @@ entry:
 define void @test_structs_unhandled() {
 entry:
   call void @has_struct_arg({i32} {i32 3})
-  call void bitcast (void ({i32})* @has_struct_arg to void ({i64})*)({i64} {i64 4})
-  call {i32, i32} bitcast (i32 ()* @has_i32_ret to {i32, i32} ()*)()
+  call void @has_struct_arg({i64} {i64 4})
+  call {i32, i32} @has_i32_ret()
   ret void
 }
 
@@ -110,22 +99,21 @@ entry:
 ; CHECK-NEXT: i32.store   0($[[L5:[0-9]+]]), $pop[[L4]]{{$}}
 ; CHECK-NEXT: call        .Lplain_bitcast, $[[L5]]{{$}}
 define void @test_varargs() {
-  call void bitcast (void (...)* @vararg to void (i32)*)(i32 0)
-  call void (...) bitcast (void (i32)* @plain to void (...)*)(i32 0)
+  call void @vararg(i32 0)
+  call void (...) @plain(i32 0)
   ret void
 }
 
 ; Don't use wrappers when the value is stored in memory
 
- at global_func = hidden local_unnamed_addr global void ()* null
+ at global_func = hidden local_unnamed_addr global ptr null
 
 ; CHECK-LABEL: test_store:
 ; CHECK:      i32.const   $push[[L0:[0-9]+]]=, 0{{$}}
 ; CHECK-NEXT: i32.const   $push[[L1:[0-9]+]]=, has_i32_ret{{$}}
 ; CHECK-NEXT: i32.store   global_func($pop[[L0]]), $pop[[L1]]{{$}}
 define void @test_store() {
-  %1 = bitcast i32 ()* @has_i32_ret to void ()*
-  store void ()* %1, void ()** @global_func
+  store ptr @has_i32_ret, ptr @global_func
   ret void
 }
 
@@ -135,14 +123,14 @@ define void @test_store() {
 ; CHECK-NEXT: i32.load    $push[[L1:[0-9]+]]=, global_func($pop[[L0]]){{$}}
 ; CHECK-NEXT: call_indirect $push{{[0-9]+}}=, $pop[[L1]]{{$}}
 define i32 @test_load() {
-  %1 = load i32 ()*, i32 ()** bitcast (void ()** @global_func to i32 ()**)
+  %1 = load ptr, ptr @global_func
   %2 = call i32 %1()
   ret i32 %2
 }
 
 ; Don't use wrappers when the value is passed to a function call
 
-declare void @call_func(i32 ()*)
+declare void @call_func(ptr)
 
 ; CHECK-LABEL: test_argument:
 ; CHECK:      i32.const   $push[[L0:[0-9]+]]=, has_i32_ret{{$}}
@@ -150,8 +138,8 @@ declare void @call_func(i32 ()*)
 ; CHECK-NEXT: i32.const   $push[[L1:[0-9]+]]=, has_i32_arg{{$}}
 ; CHECK-NEXT: call        call_func, $pop[[L1]]{{$}}
 define void @test_argument() {
-  call void @call_func(i32 ()* @has_i32_ret)
-  call void @call_func(i32 ()* bitcast (void (i32)* @has_i32_arg to i32 ()*))
+  call void @call_func(ptr @has_i32_ret)
+  call void @call_func(ptr @has_i32_arg)
   ret void
 }
 
@@ -164,61 +152,45 @@ define void @test_argument() {
 ; CHECK:      i32.const   $push[[L3:[0-9]+]]=, call_func{{$}}
 ; CHECK-NEXT: i32.const   $push[[L2:[0-9]+]]=, has_i32_arg{{$}}
 ; CHECK-NEXT: call        invoke_vi, $pop[[L3]], $pop[[L2]]{{$}}
-; TYPED:      i32.const   $push[[L4:[0-9]+]]=, .Lhas_i32_arg_bitcast.2{{$}}
-; OPAQUE:     i32.const   $push[[L4:[0-9]+]]=, .Lhas_i32_arg_bitcast{{$}}
+; CHECK:     i32.const   $push[[L4:[0-9]+]]=, .Lhas_i32_arg_bitcast{{$}}
 ; CHECK-NEXT: call        invoke_v, $pop[[L4]]{{$}}
 declare i32 @personality(...)
-define void @test_invoke() personality i32 (...)* @personality {
+define void @test_invoke() personality ptr @personality {
 entry:
-  invoke void @call_func(i32 ()* @has_i32_ret)
+  invoke void @call_func(ptr @has_i32_ret)
           to label %cont unwind label %lpad
 
 cont:
-  invoke void @call_func(i32 ()* bitcast (void (i32)* @has_i32_arg to i32 ()*))
+  invoke void @call_func(ptr @has_i32_arg)
           to label %cont2 unwind label %lpad
 
 cont2:
-  invoke void bitcast (void (i32)* @has_i32_arg to void ()*)()
+  invoke void @has_i32_arg()
           to label %end unwind label %lpad
 
 lpad:
-  %0 = landingpad { i8*, i32 }
-          catch i8* null
+  %0 = landingpad { ptr, i32 }
+          catch ptr null
   br label %end
 
 end:
   ret void
 }
 
-; TYPED-LABEL: .Lhas_i32_arg_bitcast:
-; TYPED-NEXT: .functype .Lhas_i32_arg_bitcast (i32, i32) -> ()
-; TYPED-NEXT: call        has_i32_arg, $1{{$}}
-; TYPED-NEXT: end_function
-
-; TYPED-LABEL: .Lhas_i32_arg_bitcast.1:
-; TYPED-NEXT: .functype .Lhas_i32_arg_bitcast.1 (i32, i32) -> ()
-; TYPED-NEXT: call        has_i32_arg, $0{{$}}
-; TYPED-NEXT: end_function
-
-; TYPED-LABEL: .Lhas_i32_arg_bitcast.2:
-; TYPED-NEXT: .functype	.Lhas_i32_arg_bitcast.2 () -> ()
-; TYPED-NEXT: call        has_i32_arg, $0{{$}}
-; TYPED-NEXT: end_function
-
-; OPAQUE-LABEL: .Lhas_i32_arg_bitcast:
-; OPAQUE-NEXT: .functype	.Lhas_i32_arg_bitcast () -> ()
-; OPAQUE-NEXT: call        has_i32_arg, $0{{$}}
-; OPAQUE-NEXT: end_function
-
-; OPAQUE-LABEL: .Lhas_i32_arg_bitcast.1:
-; OPAQUE-NEXT: .functype .Lhas_i32_arg_bitcast.1 (i32, i32) -> ()
-; OPAQUE-NEXT: call        has_i32_arg, $1{{$}}
-; OPAQUE-NEXT: end_function
-
-; OPAQUE-LABEL: .Lhas_i32_arg_bitcast.2:
-; OPAQUE-NEXT: .functype .Lhas_i32_arg_bitcast.2 (i32, i32) -> ()
-; OPAQUE-NEXT: call        has_i32_arg, $0{{$}}
-; OPAQUE-NEXT: end_function
+; CHECK-LABEL: .Lhas_i32_arg_bitcast:
+; CHECK-NEXT: .functype	.Lhas_i32_arg_bitcast () -> ()
+; CHECK-NEXT: call        has_i32_arg, $0{{$}}
+; CHECK-NEXT: end_function
+
+; CHECK-LABEL: .Lhas_i32_arg_bitcast.1:
+; CHECK-NEXT: .functype .Lhas_i32_arg_bitcast.1 (i32, i32) -> ()
+; CHECK-NEXT: call        has_i32_arg, $1{{$}}
+; CHECK-NEXT: end_function
+
+; CHECK-LABEL: .Lhas_i32_arg_bitcast.2:
+; CHECK-NEXT: .functype .Lhas_i32_arg_bitcast.2 (i32, i32) -> ()
+; CHECK-NEXT: call        has_i32_arg, $0{{$}}
+; CHECK-NEXT: end_function
 
 ; CHECK-LABEL: .Lhas_i32_ret_bitcast:
 ; CHECK:      call        $drop=, has_i32_ret{{$}}


        


More information about the llvm-commits mailing list