xref: /llvm-project/llvm/test/Transforms/PGOProfile/icp_invoke_nouse.ll (revision 9ff36df5a4a7d52c51e950522870bb64912688d2)
1b5d884a3SFangrui Song; RUN: opt < %s -icp-lto -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICP
27b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
4cee313d2SEric Christopher
5*9ff36df5SFangrui Song@_ZTISt9exception = external constant ptr
6*9ff36df5SFangrui Song@pfptr = global ptr null, align 8
7cee313d2SEric Christopher
8cee313d2SEric Christopherdefine internal i32 @_ZL4bar1v() !PGOFuncName !0 {
9cee313d2SEric Christopherentry:
10cee313d2SEric Christopher  ret i32 100
11cee313d2SEric Christopher}
12cee313d2SEric Christopher
13cee313d2SEric Christopher; Function Attrs: uwtable
14*9ff36df5SFangrui Songdefine i32 @_Z3fooi(i32 %x) local_unnamed_addr personality ptr @__gxx_personality_v0 {
15cee313d2SEric Christopherentry:
16cee313d2SEric Christopher  %tobool = icmp eq i32 %x, 0
17cee313d2SEric Christopher  br i1 %tobool, label %if.end, label %cleanup
18cee313d2SEric Christopher
19cee313d2SEric Christopherif.end:                                           ; preds = %entry
20*9ff36df5SFangrui Song  %fptr = load ptr, ptr @pfptr, align 8
21*9ff36df5SFangrui Song; ICP:  [[CMP_IC1:%[0-9]+]] = icmp eq ptr %fptr, @_ZL4bar1v
22cee313d2SEric Christopher; ICP:  br i1 [[CMP_IC1]], label %[[TRUE_LABEL_IC1:.*]], label %[[FALSE_LABEL_IC1:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
23cee313d2SEric Christopher; ICP:[[TRUE_LABEL_IC1]]:
24cee313d2SEric Christopher; ICP:  invoke i32 @_ZL4bar1v()
25cee313d2SEric Christopher; ICP:          to label %[[DCALL_NORMAL_DEST_IC1:.*]] unwind label %lpad
26cee313d2SEric Christopher; ICP:[[FALSE_LABEL_IC1]]:
27cee313d2SEric Christopher  %call = invoke i32 %fptr()
28cee313d2SEric Christopher          to label %cleanup unwind label %lpad, !prof !1
29cee313d2SEric Christopher
30cee313d2SEric Christopher; ICP:[[DCALL_NORMAL_DEST_IC1]]:
31cee313d2SEric Christopher; ICP:  br label %cleanup
32cee313d2SEric Christopher
33cee313d2SEric Christopherlpad:                                             ; preds = %if.end
34*9ff36df5SFangrui Song  %0 = landingpad { ptr, i32 }
35cee313d2SEric Christopher          cleanup
36*9ff36df5SFangrui Song          catch ptr @_ZTISt9exception
37*9ff36df5SFangrui Song  %1 = extractvalue { ptr, i32 } %0, 1
38*9ff36df5SFangrui Song  %2 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTISt9exception)
39cee313d2SEric Christopher  %matches = icmp eq i32 %1, %2
40cee313d2SEric Christopher  br i1 %matches, label %catch, label %ehcleanup
41cee313d2SEric Christopher
42cee313d2SEric Christophercatch:                                            ; preds = %lpad
43*9ff36df5SFangrui Song  %3 = extractvalue { ptr, i32 } %0, 0
44*9ff36df5SFangrui Song  %4 = tail call ptr @__cxa_begin_catch(ptr %3)
45cee313d2SEric Christopher  tail call void @__cxa_end_catch()
46cee313d2SEric Christopher  br label %cleanup
47cee313d2SEric Christopher
48cee313d2SEric Christophercleanup:                                          ; preds = %catch, %if.end, %entry
49cee313d2SEric Christopher; ICP-NOT: %[0-9]+ = phi
50cee313d2SEric Christopher  ret i32 0
51cee313d2SEric Christopher
52cee313d2SEric Christopherehcleanup:                                        ; preds = %lpad
53*9ff36df5SFangrui Song  resume { ptr, i32 } %0
54cee313d2SEric Christopher}
55cee313d2SEric Christopher
56cee313d2SEric Christopherdeclare i32 @_Z3barv() local_unnamed_addr
57cee313d2SEric Christopher
58cee313d2SEric Christopherdeclare i32 @__gxx_personality_v0(...)
59cee313d2SEric Christopher
60cee313d2SEric Christopher; Function Attrs: nounwind readnone
61*9ff36df5SFangrui Songdeclare i32 @llvm.eh.typeid.for(ptr)
62cee313d2SEric Christopher
63*9ff36df5SFangrui Songdeclare ptr @__cxa_begin_catch(ptr) local_unnamed_addr
64cee313d2SEric Christopher
65cee313d2SEric Christopherdeclare void @__cxa_end_catch() local_unnamed_addr
66cee313d2SEric Christopher
67cee313d2SEric Christopher!0 = !{!"invoke.ll:_ZL4bar1v"}
68cee313d2SEric Christopher!1 = !{!"VP", i32 0, i64 10000, i64 -2732222848796217051, i64 10000}
69