blob: 510473eb37ddcb240bc77922076350cd100204d3 [file] [log] [blame]
Matt Arsenault90e4f712017-11-13 01:47:52 +00001; RUN: opt -S -instcombine < %s | FileCheck -enable-var-scope %s
Dehao Chenfed890e2017-03-31 15:59:52 +00002
Reid Kleckner257cb4e2017-04-13 20:26:38 +00003; Check that instcombine preserves !prof metadata when removing function
4; prototype casts.
Dehao Chenfed890e2017-03-31 15:59:52 +00005
Reid Kleckner257cb4e2017-04-13 20:26:38 +00006declare i32 @__gxx_personality_v0(...)
7declare void @__cxa_call_unexpected(i8*)
8declare void @foo(i16* %a)
Dehao Chenfed890e2017-03-31 15:59:52 +00009
Reid Kleckner257cb4e2017-04-13 20:26:38 +000010; CHECK-LABEL: @test_call()
Matt Arsenault90e4f712017-11-13 01:47:52 +000011; CHECK: call void @foo(i16* null), !prof ![[$PROF:[0-9]+]]
Reid Kleckner257cb4e2017-04-13 20:26:38 +000012define void @test_call() {
Dehao Chenfed890e2017-03-31 15:59:52 +000013 call void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null), !prof !0
14 ret void
15}
16
Reid Kleckner257cb4e2017-04-13 20:26:38 +000017; CHECK-LABEL: @test_invoke()
18; CHECK: invoke void @foo(i16* null)
Matt Arsenault90e4f712017-11-13 01:47:52 +000019; CHECK-NEXT: to label %done unwind label %lpad, !prof ![[$PROF]]
Reid Kleckner257cb4e2017-04-13 20:26:38 +000020define 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
23
24done:
25 ret void
26
27lpad:
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
32 unreachable
33}
34
Matt Arsenault90e4f712017-11-13 01:47:52 +000035; CHECK: ![[$PROF]] = !{!"branch_weights", i32 2000}
Dehao Chenfed890e2017-03-31 15:59:52 +000036!0 = !{!"VP", i32 0, i64 2000, i64 -3913987384944532146, i64 2000}
37
38!llvm.module.flags = !{!1}
39
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}