1; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN 2; RUN: opt < %s -passes=pgo-instr-gen,instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=LOWER 3; RUN: opt < %s -passes=pgo-instr-gen,instrprof -vp-static-alloc=false -S | FileCheck %s --check-prefix=LOWER 4 5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-unknown-linux-gnu" 7 8$novp_inline = comdat any 9$vp_inline = comdat any 10 11@bar = external global ptr, align 8 12 13; GEN: @__profn_novp_inline = linkonce_odr hidden constant [11 x i8] c"novp_inline" 14; GEN: @__profn_foo = private constant [3 x i8] c"foo" 15; GEN: @__profn_vp_inline = linkonce_odr hidden constant [9 x i8] c"vp_inline" 16 17;; Test that a linkonce function's address is recorded. 18;; We allow a linkonce profd to be private if the function does not use value profiling. 19; LOWER: @__profd_novp_inline.[[HASH:[0-9]+]] = private global {{.*}} @__profc_novp_inline.[[HASH]] 20; LOWER-SAME: ptr @novp_inline 21; LOWER: @__profd_foo = private {{.*}} @__profc_foo 22 23;; __profd_vp_inline.[[#]] is referenced by code and may be referenced by other 24;; text sections due to inlining. It can't be local because a linker error would 25;; occur if a prevailing text section references the non-prevailing local symbol. 26; LOWER: @__profd_vp_inline.[[FOO_HASH:[0-9]+]] = linkonce_odr hidden {{.*}} @__profc_vp_inline.[[FOO_HASH]] 27; LOWER-SAME: ptr @vp_inline 28 29define linkonce_odr void @novp_inline() comdat { 30 ret void 31} 32 33define void @foo() { 34entry: 35; GEN: @foo() 36; GEN: entry: 37; GEN-NEXT: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 [[#FOO_HASH:]], i32 1, i32 0) 38 %tmp = load ptr, ptr @bar, align 8 39; GEN: [[ICALL_TARGET:%[0-9]+]] = ptrtoint ptr %tmp to i64 40; GEN-NEXT: call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 [[#FOO_HASH]], i64 [[ICALL_TARGET]], i32 0, i32 0) 41; LOWER: call void @__llvm_profile_instrument_target(i64 %1, ptr @__profd_foo, i32 0) 42 call void %tmp() 43 ret void 44} 45 46define linkonce_odr void @vp_inline() comdat { 47entry: 48; GEN: @vp_inline() 49; GEN: entry: 50; GEN-NEXT: call void @llvm.instrprof.increment(ptr @__profn_vp_inline, i64 [[#FOO_HASH:]], i32 1, i32 0) 51 %tmp = load ptr, ptr @bar, align 8 52; GEN: [[ICALL_TARGET:%[0-9]+]] = ptrtoint ptr %tmp to i64 53; GEN-NEXT: call void @llvm.instrprof.value.profile(ptr @__profn_vp_inline, i64 [[#FOO_HASH]], i64 [[ICALL_TARGET]], i32 0, i32 0) 54; LOWER: call void @__llvm_profile_instrument_target(i64 %1, ptr @__profd_vp_inline.[[#]], i32 0) 55 call void %tmp() 56 ret void 57} 58 59@bar2 = global ptr null, align 8 60@_ZTIi = external constant ptr 61 62define i32 @foo2(i32 %arg, ptr nocapture readnone %arg1) personality ptr @__gxx_personality_v0 { 63bb: 64 %tmp2 = load ptr, ptr @bar2, align 8 65 invoke void %tmp2() 66 to label %bb10 unwind label %bb2 67; GEN: [[ICALL_TARGET2:%[0-9]+]] = ptrtoint ptr %tmp2 to i64 68; GEN-NEXT: call void @llvm.instrprof.value.profile(ptr @__profn_foo2, i64 [[FOO2_HASH:[0-9]+]], i64 [[ICALL_TARGET2]], i32 0, i32 0) 69 70bb2: ; preds = %bb 71 %tmp3 = landingpad { ptr, i32 } 72 catch ptr @_ZTIi 73 %tmp4 = extractvalue { ptr, i32 } %tmp3, 1 74 %tmp5 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi) 75 %tmp6 = icmp eq i32 %tmp4, %tmp5 76 br i1 %tmp6, label %bb7, label %bb11 77 78bb7: ; preds = %bb2 79 %tmp8 = extractvalue { ptr, i32 } %tmp3, 0 80 %tmp9 = tail call ptr @__cxa_begin_catch(ptr %tmp8) 81 tail call void @__cxa_end_catch() 82 br label %bb10 83 84bb10: ; preds = %bb7, %bb 85 ret i32 0 86 87bb11: ; preds = %bb2 88 resume { ptr, i32 } %tmp3 89} 90 91declare i32 @__gxx_personality_v0(...) 92 93; Function Attrs: nounwind readnone 94declare i32 @llvm.eh.typeid.for(ptr) #0 95 96declare ptr @__cxa_begin_catch(ptr) 97 98declare void @__cxa_end_catch() 99 100