[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / memprof.cpp
bloba8d13f3ec0210d82265acd0cbafd64122aab0b55
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=INSTRUMENT
6 // INSTRUMENT: Running pass: MemProfilerPass on main
7 // INSTRUMENT: Running pass: ModuleMemProfilerPass on [module]
9 // Avoid failures on big-endian systems that can't read the raw profile properly
10 // REQUIRES: x86_64-linux
12 // TODO: Use text profile inputs once that is available for memprof.
14 // To update the inputs below, run Inputs/update_memprof_inputs.sh
15 // RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
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=USE
20 // USE: Running pass: MemProfUsePass on [module]
22 char *foo() {
23 return new char[10];
25 int main() {
26 char *a = foo();
27 delete[] a;
28 return 0;