1; RUN: opt -S -codegenprepare < %s | FileCheck %s
2target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-pc-windows-msvc"
4
5@rtti = external global i8
6
7define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
8entry:
9  %e = alloca i8
10  %tmpcast = bitcast i8* %e to i16*
11  invoke void @_CxxThrowException(i8* null, i8* null)
12          to label %catchret.dest unwind label %catch.dispatch
13
14catch.dispatch:                                   ; preds = %entry
15  %0 = catchswitch within none [label %catch] unwind to caller
16
17catch:                                            ; preds = %catch.dispatch
18  %1 = catchpad within %0 [i8* @rtti, i32 0, i16* %tmpcast]
19  catchret from %1 to label %catchret.dest
20
21catchret.dest:                                    ; preds = %catch
22  ret void
23}
24; CHECK-LABEL: define void @test1(
25; CHECK: %[[alloca:.*]] = alloca i8
26; CHECK-NEXT: %[[bc:.*]] = bitcast i8* %[[alloca]] to i16*
27
28; CHECK: catchpad within {{.*}} [i8* @rtti, i32 0, i16* %[[bc]]]
29
30declare void @_CxxThrowException(i8*, i8*)
31
32declare i32 @__CxxFrameHandler3(...)
33