1 ; RUN: opt -S -instcombine < %s | FileCheck -enable-var-scope %s
3 ; Check that instcombine preserves !prof metadata when removing function
6 declare i32 @__gxx_personality_v0(...)
7 declare void @__cxa_call_unexpected(i8*)
8 declare void @foo(i16* %a)
10 ; CHECK-LABEL: @test_call()
11 ; CHECK: call void @foo(i16* null), !prof ![[$PROF:[0-9]+]]
12 define void @test_call() {
13 call void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null), !prof !0
17 ; CHECK-LABEL: @test_invoke()
18 ; CHECK: invoke void @foo(i16* null)
19 ; CHECK-NEXT: to label %done unwind label %lpad, !prof ![[$PROF]]
20 define void @test_invoke() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
21 invoke void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null)
22 to label %done unwind label %lpad, !prof !0
28 %lp = landingpad { i8*, i32 }
29 filter [0 x i8*] zeroinitializer
30 %ehptr = extractvalue { i8*, i32 } %lp, 0
31 tail call void @__cxa_call_unexpected(i8* %ehptr) noreturn nounwind
35 ; CHECK: ![[$PROF]] = !{!"VP", i32 0, i64 2000, i64 -3913987384944532146, i64 2000}
36 !0 = !{!"VP", i32 0, i64 2000, i64 -3913987384944532146, i64 2000}
38 !llvm.module.flags = !{!1}
40 !1 = !{i32 1, !"ProfileSummary", !2}
41 !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
42 !3 = !{!"ProfileFormat", !"InstrProf"}
43 !4 = !{!"TotalCount", i64 10000}
44 !5 = !{!"MaxCount", i64 1000}
45 !6 = !{!"MaxInternalCount", i64 1}
46 !7 = !{!"MaxFunctionCount", i64 1000}
47 !8 = !{!"NumCounts", i64 3}
48 !9 = !{!"NumFunctions", i64 3}
49 !10 = !{!"DetailedSummary", !11}
50 !11 = !{!12, !13, !14}
51 !12 = !{i32 10000, i64 1000, i32 1}
52 !13 = !{i32 999000, i64 1000, i32 1}
53 !14 = !{i32 999999, i64 1, i32 2}