Skip to content

Commit

Permalink
[WebAssembly] Fix .functype directives in tests (llvm#108748)
Browse files Browse the repository at this point in the history
For defined functions, it appears `.functype` directive should be after
the function label. Otherwise binary generation does not seem to work
correctly. Also this fixes a case that the `.functype` directive's name
is incorrect.
  • Loading branch information
aheejin authored Sep 16, 2024
1 parent 0975e2a commit dbc5900
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions llvm/test/MC/WebAssembly/eh-assembly-legacy.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

.tagtype __cpp_exception i32
.tagtype __c_longjmp i32
.functype eh_legacy_test () -> ()
.functype foo () -> ()

eh_legacy_test:
.functype eh_legacy_test () -> ()

# try-catch with catch, catch_all, throw, and rethrow
try
i32.const 3
Expand Down Expand Up @@ -55,7 +56,7 @@ eh_legacy_test:
end_function

# CHECK-LABEL: eh_legacy_test:
# CHECK-NEXT: try
# CHECK: try
# CHECK-NEXT: i32.const 3
# CHECK-NEXT: throw __cpp_exception
# CHECK-NEXT: catch __cpp_exception
Expand Down
10 changes: 5 additions & 5 deletions llvm/test/MC/WebAssembly/func-end-errors.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# assembly. This causes the parser to properly wrap up function info when there
# is no other instructions present.

.functype test0 () -> ()
test0:
.functype test0 () -> ()

.functype test1 () -> ()
# CHECK: [[@LINE+1]]:1: error: Unmatched block construct(s) at function end: function
test1:
# CHECK: [[@LINE+1]]:{{.*}}: error: Unmatched block construct(s) at function end: function
.functype test1 () -> ()
end_function

.functype test2 () -> ()
test2:
# CHECK: [[@LINE+1]]:1: error: Unmatched block construct(s) at function end: function
.functype test2 () -> ()
# CHECK: [[@LINE+1]]:{{.*}}: error: Unmatched block construct(s) at function end: function
2 changes: 1 addition & 1 deletion llvm/test/MC/WebAssembly/funcref-from-table.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.globl obtain_funcref_from_table_index

obtain_funcref_from_table_index:
.functype obtain_funcref_from_table_index(i32) -> (funcref)
.functype obtain_funcref_from_table_index (i32) -> (funcref)
local.get 0
table.get __indirect_function_table
end_function
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/WebAssembly/type-checker-br.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ br_block:
end_function

br_func:
.functype br_block () -> ()
.functype br_func () -> ()
block i32
br 1
i32.const 1
Expand Down

0 comments on commit dbc5900

Please sign in to comment.