diff options
| author | Heejin Ahn <aheejin@gmail.com> | 2018-11-16 00:47:18 +0000 |
|---|---|---|
| committer | Heejin Ahn <aheejin@gmail.com> | 2018-11-16 00:47:18 +0000 |
| commit | 095796a391e5e8343ce462ce97fdc493d20478cd (patch) | |
| tree | 53daa4333ce0a05d5da5f3b9b8998d4ed88ef4c9 /llvm/test/CodeGen/WebAssembly | |
| parent | 2f5683e6b0d3c7348929e05a2a781690e598c533 (diff) | |
| download | bcm5719-llvm-095796a391e5e8343ce462ce97fdc493d20478cd.tar.gz bcm5719-llvm-095796a391e5e8343ce462ce97fdc493d20478cd.zip | |
[WebAssembly] Split BBs after throw instructions
Summary:
`throw` instruction is a terminator in wasm, but BBs were not splitted
after `throw` instructions, causing machine instruction verifier to
fail.
This patch
- Splits BBs after `throw` instructions in WasmEHPrepare and adding an
unreachable instruction after `throw`, which will be deleted in
LateEHPrepare pass
- Refactors WasmEHPrepare into two member functions
- Changes the semantics of `eraseBBsAndChildren` in LateEHPrepare pass
to match that of WasmEHPrepare pass, which is newly added. Now
`eraseBBsAndChildren` does not delete BBs with remaining predecessors.
- Fixes style nits, making static function names conform to clang-tidy
- Re-enables the test temporarily disabled by rL346840 && rL346845
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D54571
llvm-svn: 347003
Diffstat (limited to 'llvm/test/CodeGen/WebAssembly')
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/exception.ll | 9 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/wasmehprepare.ll | 30 |
2 files changed, 34 insertions, 5 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/exception.ll b/llvm/test/CodeGen/WebAssembly/exception.ll index 0577cd43b97..b53cd0cb544 100644 --- a/llvm/test/CodeGen/WebAssembly/exception.ll +++ b/llvm/test/CodeGen/WebAssembly/exception.ll @@ -1,5 +1,5 @@ ; RUN: not llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling | FileCheck -allow-deprecated-dag-overlap %s +; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling -verify-machineinstrs | FileCheck -allow-deprecated-dag-overlap %s ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" @@ -12,10 +12,11 @@ target triple = "wasm32-unknown-unknown" declare void @llvm.wasm.throw(i32, i8*) ; CHECK-LABEL: test_throw: -; CHECK-NEXT: i32.const $push0=, 0 +; CHECK: get_local $push0=, 0 ; CHECK-NEXT: throw __cpp_exception@EVENT, $pop0 -define void @test_throw() { - call void @llvm.wasm.throw(i32 0, i8* null) +; CHECK-NOT: unreachable +define void @test_throw(i8* %p) { + call void @llvm.wasm.throw(i32 0, i8* %p) ret void } diff --git a/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll b/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll index 67e198eb058..6df7175b1ca 100644 --- a/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll +++ b/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll @@ -298,6 +298,34 @@ try.cont10: ; preds = %invoke.cont3, %catc ret void } +; Tests if instructions after a call to @llvm.wasm.throw are deleted and the +; BB's dead children are deleted. + +; CHECK-LABEL: @test6 +define i32 @test6(i1 %b, i8* %p) { +entry: + br i1 %b, label %bb.true, label %bb.false + +; CHECK: bb.true: +; CHECK-NEXT: call void @llvm.wasm.throw(i32 0, i8* %p) +; CHECK-NEXT: unreachable +bb.true: ; preds = %entry + call void @llvm.wasm.throw(i32 0, i8* %p) + br label %bb.true.0 + +; CHECK-NOT: bb.true.0 +bb.true.0: ; preds = %bb.true + br label %merge + +; CHECK: bb.false +bb.false: ; preds = %entry + br label %merge + +; CHECK: merge +merge: ; preds = %bb.true.0, %bb.false + ret i32 0 +} + declare void @foo() declare void @func(i32) declare %struct.Cleanup* @_ZN7CleanupD1Ev(%struct.Cleanup* returned) @@ -305,6 +333,7 @@ declare i32 @__gxx_wasm_personality_v0(...) declare i8* @llvm.wasm.get.exception(token) declare i32 @llvm.wasm.get.ehselector(token) declare i32 @llvm.eh.typeid.for(i8*) +declare void @llvm.wasm.throw(i32, i8*) declare i8* @__cxa_begin_catch(i8*) declare void @__cxa_end_catch() declare void @__cxa_rethrow() @@ -314,4 +343,3 @@ declare void @__clang_call_terminate(i8*) ; CHECK-DAG: declare void @llvm.wasm.landingpad.index(token, i32) ; CHECK-DAG: declare i8* @llvm.wasm.lsda() ; CHECK-DAG: declare i32 @_Unwind_CallPersonality(i8*) - |

