brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.2 KiB · 31dfce5 Raw
269 lines · plain
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling < %s | FileCheck %s2# Check that it converts to .o without errors, but don't check any output:3# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+exception-handling -o %t.o < %s4 5  .tagtype  __cpp_exception i326  .tagtype  __c_longjmp i327  .functype  foo () -> ()8 9eh_test:10  .functype  eh_test (exnref) -> ()11 12  # try_table with all four kinds of catch clauses13  block exnref14    block15      block () -> (i32, exnref)16        block i3217          try_table (catch __cpp_exception 0) (catch_ref __c_longjmp 1) (catch_all 2) (catch_all_ref 3)18            i32.const 019            throw     __cpp_exception20          end_try_table21          return22        end_block23        drop24        return25      end_block26      throw_ref27    end_block28    return29  end_block30  drop31 32  # You can use the same kind of catch clause more than once33  block34    block exnref35      block36        try_table (catch_all 0) (catch_all_ref 1) (catch_all 2)37          call  foo38        end_try_table39      end_block40      return41    end_block42    drop43  end_block44 45  # Two catch clauses targeting the same block46  block47    try_table (catch_all 0) (catch_all 0)48    end_try_table49  end_block50 51  # try_table with a return type52  block53    try_table f32 (catch_all 0)54      f32.const 0.055    end_try_table56    drop57  end_block58 59  # try_table with a multivalue type return60  block61    try_table () -> (i32, f32) (catch_all 0)62      i32.const 063      f32.const 0.064    end_try_table65    drop66    drop67  end_block68 69  # catch-less try_tables70  try_table71    call  foo72  end_try_table73 74  try_table i3275    i32.const 076  end_try_table77  drop78 79  try_table () -> (i32, f32)80    i32.const 081    f32.const 0.082  end_try_table83  drop84  drop85 86  # try_table targeting loops87  i32.const 088  loop (i32) -> ()89    local.get 090    loop (exnref) -> ()91      try_table (catch __cpp_exception 1) (catch_all_ref 0)92      end_try_table93      drop94    end_loop95    drop96  end_loop97  end_function98 99eh_legacy_test:100  .functype  eh_legacy_test () -> ()101 102  # try-catch with catch, catch_all, throw, and rethrow103  try104    i32.const 3105    throw     __cpp_exception106  catch       __cpp_exception107    drop108    rethrow 0109  catch       __c_longjmp110    drop111  catch_all112    rethrow 0113  end_try114 115  # Nested try-catch with a rethrow116  try117    call  foo118  catch_all119    try120    catch_all121      rethrow 1122    end_try123  end_try124 125  # try-catch with a single return value126  try i32127    i32.const 0128  catch       __cpp_exception129  end_try130  drop131 132  # try-catch with a mulvivalue return133  try () -> (i32, f32)134    i32.const 0135    f32.const 0.0136  catch       __cpp_exception137    f32.const 1.0138  end_try139  drop140  drop141 142  # Catch-less try143  try144    call  foo145  end_try146  end_function147 148 149# CHECK-LABEL: eh_test:150# CHECK:         block           exnref151# CHECK-NEXT:    block152# CHECK-NEXT:    block           () -> (i32, exnref)153# CHECK-NEXT:    block           i32154# CHECK-NEXT:    try_table        (catch __cpp_exception 0) (catch_ref __c_longjmp 1) (catch_all 2) (catch_all_ref 3)155# CHECK:         i32.const       0156# CHECK-NEXT:    throw           __cpp_exception157# CHECK-NEXT:    end_try_table158# CHECK-NEXT:    return159# CHECK-NEXT:    end_block160# CHECK-NEXT:    drop161# CHECK-NEXT:    return162# CHECK-NEXT:    end_block163# CHECK-NEXT:    throw_ref164# CHECK-NEXT:    end_block165# CHECK-NEXT:    return166# CHECK-NEXT:    end_block167# CHECK-NEXT:    drop168 169# CHECK:         block170# CHECK-NEXT:    block           exnref171# CHECK-NEXT:    block172# CHECK-NEXT:    try_table        (catch_all 0) (catch_all_ref 1) (catch_all 2)173# CHECK:         call    foo174# CHECK-NEXT:    end_try_table175# CHECK-NEXT:    end_block176# CHECK-NEXT:    return177# CHECK-NEXT:    end_block178# CHECK-NEXT:    drop179# CHECK-NEXT:    end_block180 181# CHECK:         block182# CHECK-NEXT:    try_table        (catch_all 0) (catch_all 0)183# CHECK:         end_try_table184# CHECK-NEXT:    end_block185 186# CHECK:         block187# CHECK-NEXT:    try_table       f32 (catch_all 0)188# CHECK:         f32.const       0x0p0189# CHECK-NEXT:    end_try_table190# CHECK-NEXT:    drop191# CHECK-NEXT:    end_block192 193# CHECK:         block194# CHECK-NEXT:    try_table       () -> (i32, f32) (catch_all 0)195# CHECK:         i32.const       0196# CHECK-NEXT:    f32.const       0x0p0197# CHECK-NEXT:    end_try_table198# CHECK-NEXT:    drop199# CHECK-NEXT:    drop200# CHECK-NEXT:    end_block201 202# CHECK:         try_table203# CHECK-NEXT:    call    foo204# CHECK-NEXT:    end_try_table205 206# CHECK:         try_table       i32207# CHECK-NEXT:    i32.const       0208# CHECK-NEXT:    end_try_table209# CHECK-NEXT:    drop210 211# CHECK:         try_table       () -> (i32, f32)212# CHECK-NEXT:    i32.const       0213# CHECK-NEXT:    f32.const       0x0p0214# CHECK-NEXT:    end_try_table215# CHECK-NEXT:    drop216# CHECK-NEXT:    drop217 218# CHECK:         i32.const       0219# CHECK-NEXT:    loop            (i32) -> ()220# CHECK-NEXT:    local.get       0221# CHECK-NEXT:    loop            (exnref) -> ()222# CHECK-NEXT:    try_table        (catch __cpp_exception 1) (catch_all_ref 0)223# CHECK:         end_try_table224# CHECK-NEXT:    drop225# CHECK-NEXT:    end_loop226# CHECK-NEXT:    drop227# CHECK-NEXT:    end_loop228 229# CHECK:       eh_legacy_test:230# CHECK:         try231# CHECK-NEXT:    i32.const       3232# CHECK-NEXT:    throw           __cpp_exception233# CHECK-NEXT:    catch           __cpp_exception234# CHECK-NEXT:    drop235# CHECK-NEXT:    rethrow         0236# CHECK-NEXT:    catch           __c_longjmp237# CHECK-NEXT:    drop238# CHECK-NEXT:    catch_all239# CHECK-NEXT:    rethrow         0240# CHECK-NEXT:    end_try241 242# CHECK:         try243# CHECK-NEXT:    call    foo244# CHECK-NEXT:    catch_all245# CHECK-NEXT:    try246# CHECK-NEXT:    catch_all247# CHECK-NEXT:    rethrow         1248# CHECK-NEXT:    end_try249# CHECK-NEXT:    end_try250 251# CHECK:         try             i32252# CHECK-NEXT:    i32.const       0253# CHECK-NEXT:    catch           __cpp_exception254# CHECK-NEXT:    end_try255# CHECK-NEXT:    drop256 257# CHECK:         try             () -> (i32, f32)258# CHECK-NEXT:    i32.const       0259# CHECK-NEXT:    f32.const       0x0p0260# CHECK-NEXT:    catch           __cpp_exception261# CHECK-NEXT:    f32.const       0x1p0262# CHECK-NEXT:    end_try263# CHECK-NEXT:    drop264# CHECK-NEXT:    drop265 266# CHECK:         try267# CHECK-NEXT:    call    foo268# CHECK-NEXT:    end_try269