Files
clang-p2996/llvm/test/CodeGen/WebAssembly/wasm-eh-invalid-personality.ll
Heejin Ahn 90073e8de3 [WebAssembly] Error out on invalid personality functions
Without explicitly checking and erroring out, an invalid personality
function, which is not `__gxx_wasm_personality_v0`, caused
a segmentation fault down the line because `WasmEHFuncInfo` was not
created. This explicitly checks the validity of personality functions in
functions with EH pads and errors out explicitly with a helpful error
message. This also adds some more assertions to ensure `WasmEHFuncInfo`
is correctly created and non-null.

Invalid personality functions wouldn't be generated by our Clang, but
can be present in handwritten ll files, and more often, in files
transformed by passes like `metarenamer`, which is often used with
`bugpoint` to simplify names in `bugpoint`-reduced files.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D152203
2023-06-08 16:59:49 -07:00

27 lines
983 B
LLVM

; RUN: not --crash llc < %s -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling 2>&1 | FileCheck %s
target triple = "wasm32-unknown-unknown"
; Tests if the compiler correctly errors out when a function having EH pads does
; not have a correct Wasm personality function.
define void @test() personality ptr @invalid_personality {
; CHECK: LLVM ERROR: Function 'test' does not have a correct Wasm personality function '__gxx_wasm_personality_v0'
entry:
invoke void @foo()
to label %try.cont unwind label %catch.dispatch
catch.dispatch: ; preds = %entry
%0 = catchswitch within none [label %catch.start] unwind to caller
catch.start: ; preds = %catch.dispatch
%1 = catchpad within %0 [ptr null]
catchret from %1 to label %try.cont
try.cont: ; preds = %catch, %entry
ret void
}
declare void @foo()
declare i32 @invalid_personality(...)