2022-09-23 06:43:07 -07:00
|
|
|
// Test if memprof instrumentation and use pass are invoked.
|
|
|
|
//
|
|
|
|
// Instrumentation:
|
|
|
|
// Ensure Pass MemProfilerPass and ModuleMemProfilerPass are invoked.
|
|
|
|
// RUN: %clang_cc1 -O2 -fmemory-profile %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INSTRUMENT
|
|
|
|
// INSTRUMENT: Running pass: MemProfilerPass on main
|
|
|
|
// INSTRUMENT: Running pass: ModuleMemProfilerPass on [module]
|
|
|
|
|
|
|
|
// Avoid failures on big-endian systems that can't read the raw profile properly
|
|
|
|
// REQUIRES: x86_64-linux
|
|
|
|
|
|
|
|
// TODO: Use text profile inputs once that is available for memprof.
|
|
|
|
//
|
2023-03-09 03:55:39 +00:00
|
|
|
// To update the inputs below, run Inputs/update_memprof_inputs.sh
|
2022-09-23 06:43:07 -07:00
|
|
|
// RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
|
|
|
|
|
|
|
|
// Profile use:
|
|
|
|
// Ensure Pass PGOInstrumentationUse is invoked with the memprof-only profile.
|
2023-07-11 12:08:08 -07:00
|
|
|
// RUN: %clang_cc1 -O2 -fmemory-profile-use=%t.memprofdata %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=USE
|
|
|
|
// USE: Running pass: MemProfUsePass on [module]
|
2022-09-23 06:43:07 -07:00
|
|
|
|
|
|
|
char *foo() {
|
|
|
|
return new char[10];
|
|
|
|
}
|
|
|
|
int main() {
|
|
|
|
char *a = foo();
|
|
|
|
delete[] a;
|
|
|
|
return 0;
|
|
|
|
}
|