1// RUN: mkdir -p %t.d 2// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c 3// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t -rpath %t.d %t.d/t.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c 4// RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t 5// RUN: llvm-profdata merge -o %t.profdata %t.profraw 6// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c 7// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED 8 9// IR level instrumentation 10// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c 11// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir %t.d/t.ir.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c 12// Profile data from shared library will be concatenated to the same raw file. 13// RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir 14// RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw 15// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c 16// RUN: llvm-profdata merge -text %t.ir.profdata -o %t.ir.proftxt 17// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED 18// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt 19 20// Same as above but with profile online merging enabled. 21// RUN: rm -fr %t.prof/ 22// RUN: mkdir -p %t.prof/ 23// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.m.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c 24// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.m %t.d/t.ir.m.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c 25// RUN: env LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.m 26// RUN: llvm-profdata merge -o %t.ir.m.profdata -dump-input-file-list %t.prof/ | count 2 27// RUN: llvm-profdata merge -o %t.ir.m.profdata %t.prof/ 28// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c 29// RUN: llvm-profdata merge -text %t.ir.m.profdata -o %t.ir.m.proftxt 30// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED 31// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.m.proftxt 32 33 34// IR level instrumentation: dynamic memory allocation 35// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c 36// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.dyn %t.d/t.ir.dyn.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c 37// RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn 38// RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw 39// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c 40// RUN: llvm-profdata merge -text %t.ir.dyn.profdata -o %t.ir.dyn.proftxt 41// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED 42// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt 43 44// IR level instrumentation: main program uses static counter, shared library uses dynamic memory alloc. 45// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c 46// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.mixed %t.d/t.ir.dyn.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c 47// RUN: env LLVM_PROFILE_FILE=%t.ir.mixed.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.mixed 48// RUN: llvm-profdata merge -o %t.ir.mixed.profdata %t.ir.mixed.profraw 49// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c 50// RUN: llvm-profdata merge -text %t.ir.mixed.profdata -o %t.ir.mixed.proftxt 51// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED 52// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.mixed.proftxt 53