xref: /llvm-project/llvm/test/Transforms/Sink/catchswitch.ll (revision a198d2041e8a5c9520d3df59887ca3c744b15d82)
1211cf8a3SBjorn Pettersson; RUN: opt -passes=sink -S < %s | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christophertarget datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4cee313d2SEric Christophertarget triple = "i686-pc-windows-msvc"
5cee313d2SEric Christopher
6*a198d204SMatt Arsenaultdefine void @h() personality ptr @__CxxFrameHandler3 {
7cee313d2SEric Christopherentry:
8cee313d2SEric Christopher  %call = call i32 @g(i32 1) readnone
9*a198d204SMatt Arsenault  invoke void @_CxxThrowException(ptr null, ptr null) noreturn
10cee313d2SEric Christopher          to label %unreachable unwind label %catch.dispatch
11cee313d2SEric Christopher
12cee313d2SEric Christophercatch.dispatch:                                   ; preds = %entry
13cee313d2SEric Christopher  %cs = catchswitch within none [label %catch] unwind to caller
14cee313d2SEric Christopher
15cee313d2SEric Christophercatch:                                            ; preds = %catch.dispatch
16*a198d204SMatt Arsenault  %cp = catchpad within %cs [ptr null, i32 64, ptr null]
17cee313d2SEric Christopher  catchret from %cp to label %try.cont
18cee313d2SEric Christopher
19cee313d2SEric Christophertry.cont:                                         ; preds = %catch
20cee313d2SEric Christopher  call void @k(i32 %call)
21cee313d2SEric Christopher  ret void
22cee313d2SEric Christopher
23cee313d2SEric Christopherunreachable:                                      ; preds = %entry
24cee313d2SEric Christopher  unreachable
25cee313d2SEric Christopher}
26cee313d2SEric Christopher
27*a198d204SMatt Arsenaultdeclare x86_stdcallcc void @_CxxThrowException(ptr, ptr)
28cee313d2SEric Christopher
29cee313d2SEric Christopherdeclare i32 @__CxxFrameHandler3(...)
30cee313d2SEric Christopher
31cee313d2SEric Christopherdeclare i32 @g(i32) readnone
32cee313d2SEric Christopher
33cee313d2SEric Christopherdeclare void @k(i32)
34cee313d2SEric Christopher
35cee313d2SEric Christopher; CHECK-LABEL: define void @h(
36cee313d2SEric Christopher; CHECK: call i32 @g(i32 1)
37cee313d2SEric Christopher; CHECK-NEXT: invoke void @_CxxThrowException(
38