• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -instcombine < %s | FileCheck -enable-var-scope %s
2
3; Check that instcombine preserves !prof metadata when removing function
4; prototype casts.
5
6declare i32 @__gxx_personality_v0(...)
7declare void @__cxa_call_unexpected(i8*)
8declare void @foo(i16* %a)
9
10; CHECK-LABEL: @test_call()
11; CHECK: call void @foo(i16* null), !prof ![[$PROF:[0-9]+]]
12define void @test_call() {
13  call void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null), !prof !0
14  ret void
15}
16
17; CHECK-LABEL: @test_invoke()
18; CHECK: invoke void @foo(i16* null)
19; CHECK-NEXT: to label %done unwind label %lpad, !prof ![[$PROF]]
20define 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
35; CHECK: ![[$PROF]] = !{!"VP", i32 0, i64 2000, i64 -3913987384944532146, i64 2000}
36!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}
54