30 lines · cpp
1// Test if memprof instrumentation and use pass are invoked.2//3// Instrumentation:4// Ensure Pass MemProfilerPass and ModuleMemProfilerPass are invoked.5// RUN: %clang_cc1 -O2 -fmemory-profile %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INSTRUMENT6// INSTRUMENT: Running pass: MemProfilerPass on main7// INSTRUMENT: Running pass: ModuleMemProfilerPass on [module]8 9// Avoid failures on big-endian systems that can't read the raw profile properly10// REQUIRES: x86_64-linux11 12// TODO: Use text profile inputs once that is available for memprof.13//14// To update the inputs below, run Inputs/update_memprof_inputs.sh15// RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata16 17// Profile use:18// Ensure Pass PGOInstrumentationUse is invoked with the memprof-only profile.19// RUN: %clang_cc1 -O2 -fmemory-profile-use=%t.memprofdata %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=USE20// USE: Running pass: MemProfUsePass on [module]21 22char *foo() {23 return new char[10];24}25int main() {26 char *a = foo();27 delete[] a;28 return 0;29}30