1; RUN: opt -S -loop-sink < %s | FileCheck %s
2; RUN: opt -S -verify-memoryssa -enable-mssa-in-legacy-loop-sink -loop-sink < %s | FileCheck %s
3; RUN: opt -S -aa-pipeline=basic-aa -passes=loop-sink < %s | FileCheck %s
4; RUN: opt -S -verify-memoryssa -enable-mssa-in-loop-sink -aa-pipeline=basic-aa -passes=loop-sink < %s | FileCheck %s
5
6target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-pc-windows-msvc19.13.26128"
8
9%struct.FontInfoData = type { i32 (...)** }
10%struct.S = type { i8 }
11
12; CHECK: @pr38462
13; Make sure not to assert by trying to sink into catch.dispatch.
14
15define void @pr38462(%struct.FontInfoData* %this) personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) !prof !1 {
16entry:
17  %s = alloca %struct.S
18  %call6 = call i32 @f()
19  %tobool7 = icmp eq i32 %call6, 0
20  br i1 %tobool7, label %for.body.lr.ph, label %for.cond.cleanup
21
22for.body.lr.ph:
23  %0 = getelementptr inbounds %struct.S, %struct.S* %s, i64 0, i32 0
24  br label %for.body
25
26for.cond.cleanup.loopexit:
27  br label %for.cond.cleanup
28
29for.cond.cleanup:
30  ret void
31
32for.body:
33  %call2 = invoke i32 @f() to label %__try.cont unwind label %catch.dispatch
34
35catch.dispatch:
36  %1 = catchswitch within none [label %__except] unwind to caller
37
38__except:
39  %2 = catchpad within %1 [i8* null]
40  catchret from %2 to label %__except3
41
42__except3:
43  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %0)
44  %call.i = call zeroext i1 @g(%struct.S* nonnull %s)
45  br i1 %call.i, label %if.then.i, label %exit
46
47if.then.i:
48  %call2.i = call i32 @f()
49  br label %exit
50
51exit:
52  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %0)
53  br label %__try.cont
54
55__try.cont:
56  %call = call i32 @f()
57  %tobool = icmp eq i32 %call, 0
58  br i1 %tobool, label %for.body, label %for.cond.cleanup.loopexit
59}
60
61declare i32 @__C_specific_handler(...)
62declare i32 @f()
63declare zeroext i1 @g(%struct.S*)
64declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
65declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
66
67!1 = !{!"function_entry_count", i64 1}
68
69