1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -prune-eh -enable-new-pm=0 < %s | FileCheck --check-prefixes=ALL,OLDPM %s
3 ; RUN: opt -S -passes='function-attrs,function(simplifycfg)' < %s | FileCheck --check-prefixes=ALL,NEWPM %s
5 declare void @may_throw()
7 ; @callee below may be an optimized form of this function, which can
8 ; throw at runtime (see r265762 for more details):
10 ; define linkonce_odr void @callee(i32* %ptr) noinline {
12 ; %val0 = load atomic i32, i32* %ptr unordered, align 4
13 ; %val1 = load atomic i32, i32* %ptr unordered, align 4
14 ; %cmp = icmp eq i32 %val0, %val1
15 ; br i1 %cmp, label %left, label %right
21 ; call void @may_throw()
25 define linkonce_odr void @callee(i32* %ptr) noinline {
32 define i32 @caller(i32* %ptr) personality i32 3 {
33 ; OLDPM-LABEL: @caller(
35 ; OLDPM-NEXT: invoke void @callee(i32* [[PTR:%.*]])
36 ; OLDPM-NEXT: to label [[NORMAL:%.*]] unwind label [[UNWIND:%.*]]
38 ; OLDPM-NEXT: ret i32 1
40 ; OLDPM-NEXT: [[RES:%.*]] = landingpad { i8*, i32 }
42 ; OLDPM-NEXT: ret i32 2
44 ; NEWPM-LABEL: @caller(
46 ; NEWPM-NEXT: invoke void @callee(i32* [[PTR:%.*]])
47 ; NEWPM-NEXT: to label [[COMMON_RET:%.*]] unwind label [[UNWIND:%.*]]
49 ; NEWPM-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 2, [[UNWIND]] ], [ 1, [[ENTRY:%.*]] ]
50 ; NEWPM-NEXT: ret i32 [[COMMON_RET_OP]]
52 ; NEWPM-NEXT: [[RES:%.*]] = landingpad { i8*, i32 }
54 ; NEWPM-NEXT: br label [[COMMON_RET]]
57 invoke void @callee(i32* %ptr)
58 to label %normal unwind label %unwind
64 %res = landingpad { i8*, i32 }