12f7ea054SFangrui Song;; Check that static counters are allocated for value profiler 2acead46aSFangrui Song; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC 3acead46aSFangrui Song; RUN: opt < %s -mtriple=powerpc-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC 4acead46aSFangrui Song; RUN: opt < %s -mtriple=sparc-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC 5acead46aSFangrui Song; RUN: opt < %s -mtriple=s390x-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT 6acead46aSFangrui Song; RUN: opt < %s -mtriple=powerpc64-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT 7acead46aSFangrui Song; RUN: opt < %s -mtriple=sparc64-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT 8acead46aSFangrui Song; RUN: opt < %s -mtriple=mips-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-SEXT 9acead46aSFangrui Song; RUN: opt < %s -mtriple=mips64-unknown-linux -passes=instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-SEXT 10acead46aSFangrui Song; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -vp-static-alloc=false -S | FileCheck %s --check-prefix=DYN 112f7ea054SFangrui Song 12401f7680SQiongsi Wu;; Check that counters have the correct alignments. 13401f7680SQiongsi Wu; RUN: opt %s -mtriple=powerpc64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN 14401f7680SQiongsi Wu; RUN: opt %s -mtriple=powerpc-ibm-aix -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN 15401f7680SQiongsi Wu; RUN: opt %s -mtriple=powerpc64-ibm-aix -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN 16401f7680SQiongsi Wu; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN 172f7ea054SFangrui Song 182f7ea054SFangrui Song@__profn_foo = private constant [3 x i8] c"foo" 192f7ea054SFangrui Song@__profn_bar = private constant [3 x i8] c"bar" 202f7ea054SFangrui Song 219ff36df5SFangrui Songdefine i32 @foo(ptr ) { 229ff36df5SFangrui Song call void @llvm.instrprof.increment(ptr @__profn_foo, i64 12884901887, i32 1, i32 0) 239ff36df5SFangrui Song %2 = ptrtoint ptr %0 to i64 249ff36df5SFangrui Song call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 12884901887, i64 %2, i32 0, i32 0) 252f7ea054SFangrui Song %3 = tail call i32 %0() 262f7ea054SFangrui Song ret i32 %3 272f7ea054SFangrui Song} 282f7ea054SFangrui Song 292f7ea054SFangrui Song$bar = comdat any 302f7ea054SFangrui Song 319ff36df5SFangrui Songdefine i32 @bar(ptr ) comdat { 322f7ea054SFangrui Songentry: 339ff36df5SFangrui Song call void @llvm.instrprof.increment(ptr @__profn_bar, i64 12884901887, i32 1, i32 0) 349ff36df5SFangrui Song %1 = ptrtoint ptr %0 to i64 359ff36df5SFangrui Song call void @llvm.instrprof.value.profile(ptr @__profn_bar, i64 12884901887, i64 %1, i32 0, i32 0) 362f7ea054SFangrui Song %2 = tail call i32 %0() 372f7ea054SFangrui Song ret i32 %2 382f7ea054SFangrui Song} 392f7ea054SFangrui Song 402f7ea054SFangrui Song; Function Attrs: nounwind 419ff36df5SFangrui Songdeclare void @llvm.instrprof.increment(ptr, i64, i32, i32) #0 422f7ea054SFangrui Song 432f7ea054SFangrui Song; Function Attrs: nounwind 449ff36df5SFangrui Songdeclare void @llvm.instrprof.value.profile(ptr, i64, i64, i32, i32) #0 452f7ea054SFangrui Song 462f7ea054SFangrui Songattributes #0 = { nounwind } 472f7ea054SFangrui Song 48*66b919cbSArthur Eubanks; STATIC: @__profvp_foo = private global [1 x i64] zeroinitializer, section "{{[^"]+}}",{{.*}} comdat($__profc_foo) 49*66b919cbSArthur Eubanks; STATIC: @__profvp_bar = private global [1 x i64] zeroinitializer, section "{{[^"]+}}",{{.*}} comdat($__profc_bar) 502f7ea054SFangrui Song; STATIC: @__llvm_prf_vnodes 512f7ea054SFangrui Song 522f7ea054SFangrui Song; DYN-NOT: @__profvp_foo 532f7ea054SFangrui Song; DYN-NOT: @__llvm_prf_vnodes 542f7ea054SFangrui Song 552f7ea054SFangrui Song;; __llvm_prf_vnodes and __llvm_prf_nm are not referenced by other metadata sections. 562f7ea054SFangrui Song;; We have to conservatively place them in llvm.used. 572f7ea054SFangrui Song; STATIC: @llvm.used = appending global 582f7ea054SFangrui Song; STATIC-SAME: @__llvm_prf_vnodes 592f7ea054SFangrui Song; STATIC-SAME: @__llvm_prf_nm 602f7ea054SFangrui Song 619ff36df5SFangrui Song; STATIC: call void @__llvm_profile_instrument_target(i64 %3, ptr @__profd_foo, i32 0) 629ff36df5SFangrui Song; STATIC-EXT: call void @__llvm_profile_instrument_target(i64 %3, ptr @__profd_foo, i32 zeroext 0) 639ff36df5SFangrui Song; STATIC-SEXT: call void @__llvm_profile_instrument_target(i64 %3, ptr @__profd_foo, i32 signext 0) 642f7ea054SFangrui Song 659ff36df5SFangrui Song; STATIC: declare void @__llvm_profile_instrument_target(i64, ptr, i32) 669ff36df5SFangrui Song; STATIC-EXT: declare void @__llvm_profile_instrument_target(i64, ptr, i32 zeroext) 679ff36df5SFangrui Song; STATIC-SEXT: declare void @__llvm_profile_instrument_target(i64, ptr, i32 signext) 68401f7680SQiongsi Wu 69401f7680SQiongsi Wu; ALIGN: @__profc_foo = private global {{.*}} section "__llvm_prf_cnts",{{.*}} align 8 70401f7680SQiongsi Wu; ALIGN: @__profvp_foo = private global {{.*}} section "__llvm_prf_vals",{{.*}} align 8 71401f7680SQiongsi Wu; ALIGN: @__profd_foo = private global {{.*}} section "__llvm_prf_data",{{.*}} align 8 72401f7680SQiongsi Wu; ALIGN: @__profc_bar = private global {{.*}} section "__llvm_prf_cnts",{{.*}} align 8 73401f7680SQiongsi Wu; ALIGN: @__profvp_bar = private global {{.*}} section "__llvm_prf_vals",{{.*}} align 8 74401f7680SQiongsi Wu; ALIGN: @__profd_bar = private global {{.*}} section "__llvm_prf_data",{{.*}} align 8 75*66b919cbSArthur Eubanks; ALIGN: @__llvm_prf_vnodes = private global {{.*}} section "__llvm_prf_vnds",{{.*}} align 8 76*66b919cbSArthur Eubanks; ALIGN: @__llvm_prf_nm = private constant {{.*}} section "__llvm_prf_names",{{.*}} align 1 77