Home | History | Annotate | Download | only in PGOProfile
      1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
      2 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
      3 ; RUN: opt < %s -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefix=LOWER
      4 
      5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      6 target triple = "x86_64-unknown-linux-gnu"
      7 
      8 $foo3 = comdat any
      9 
     10 @bar = external global void ()*, align 8
     11 ; GEN: @__profn_foo = private constant [3 x i8] c"foo"
     12 
     13 define void @foo() {
     14 entry:
     15 ; GEN: entry:
     16 ; GEN-NEXT: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 12884901887, i32 1, i32 0)
     17   %tmp = load void ()*, void ()** @bar, align 8
     18 ; GEN: [[ICALL_TARGET:%[0-9]+]] = ptrtoint void ()* %tmp to i64
     19 ; GEN-NEXT: call void @llvm.instrprof.value.profile(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 12884901887, i64 [[ICALL_TARGET]], i32 0, i32 0)
     20   call void %tmp()
     21   ret void
     22 }
     23 
     24 @bar2 = global void ()* null, align 8
     25 @_ZTIi = external constant i8*
     26 
     27 define i32 @foo2(i32 %arg, i8** nocapture readnone %arg1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
     28 bb:
     29   %tmp2 = load void ()*, void ()** @bar2, align 8
     30   invoke void %tmp2()
     31           to label %bb10 unwind label %bb2
     32 ; GEN: [[ICALL_TARGET2:%[0-9]+]] = ptrtoint void ()* %tmp2 to i64
     33 ; GEN-NEXT: call void @llvm.instrprof.value.profile(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_foo2, i32 0, i32 0), i64 38432627612, i64 [[ICALL_TARGET2]], i32 0, i32 0)
     34 
     35 bb2:                                              ; preds = %bb
     36   %tmp3 = landingpad { i8*, i32 }
     37           catch i8* bitcast (i8** @_ZTIi to i8*)
     38   %tmp4 = extractvalue { i8*, i32 } %tmp3, 1
     39   %tmp5 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
     40   %tmp6 = icmp eq i32 %tmp4, %tmp5
     41   br i1 %tmp6, label %bb7, label %bb11
     42 
     43 bb7:                                              ; preds = %bb2
     44   %tmp8 = extractvalue { i8*, i32 } %tmp3, 0
     45   %tmp9 = tail call i8* @__cxa_begin_catch(i8* %tmp8)
     46   tail call void @__cxa_end_catch()
     47   br label %bb10
     48 
     49 bb10:                                             ; preds = %bb7, %bb
     50   ret i32 0
     51 
     52 bb11:                                             ; preds = %bb2
     53   resume { i8*, i32 } %tmp3
     54 }
     55 
     56 ; Test that comdat function's address is recorded.
     57 ; LOWER: @__profd_foo3 = linkonce_odr{{.*}}@foo3
     58 ; Function Attrs: nounwind uwtable
     59 define linkonce_odr i32 @foo3()  comdat  {
     60   ret i32 1
     61 }
     62 
     63 declare i32 @__gxx_personality_v0(...)
     64 
     65 ; Function Attrs: nounwind readnone
     66 declare i32 @llvm.eh.typeid.for(i8*) #0
     67 
     68 declare i8* @__cxa_begin_catch(i8*)
     69 
     70 declare void @__cxa_end_catch()
     71 
     72