Debian Codegraph @

clang/test/CodeGen/memprof-pgho.cpp

raw
1 // Test end-to-end optimization pipeline with PGHO, that it does not interfere
2 // with other allocation instrumentation features.
3 //
4 // RUN: split-file %s %t
5 // RUN: llvm-profdata merge %t/memprof.yaml -o %t/use.profdata
6 // RUN: %clang_cc1 -O2 -debug-info-kind=limited -fmemory-profile-use=%t/use.profdata -mllvm -optimize-hot-cold-new \
7 // RUN: %t/src.cpp -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
8 // RUN: %clang_cc1 -O2 -fsanitize=alloc-token -debug-info-kind=limited -fmemory-profile-use=%t/use.profdata -mllvm -optimize-hot-cold-new \
9 // RUN: %t/src.cpp -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,ALLOCTOKEN
10
11 //--- memprof.yaml
12 ---
13 HeapProfileRecords:
14 - GUID: 0x7f8d88fcc70a347b
15 AllocSites:
16 - Callstack:
17 - { Function: 0x7f8d88fcc70a347b, LineOffset: 1, Column: 10, IsInlineFrame: false }
18 - { Function: 0xdb956436e78dd5fa, LineOffset: 1, Column: 13, IsInlineFrame: false }
19 MemInfoBlock:
20 AllocCount: 1
21 TotalAccessCount: 0
22 MinAccessCount: 0
23 MaxAccessCount: 0
24 TotalSize: 10
25 MinSize: 10
26 MaxSize: 10
27 AllocTimestamp: 100
28 DeallocTimestamp: 100
29 TotalLifetime: 100000
30 MinLifetime: 100000
31 MaxLifetime: 100000
32 AllocCpuId: 0
33 DeallocCpuId: 0
34 NumMigratedCpu: 0
35 NumLifetimeOverlaps: 0
36 NumSameAllocCpu: 0
37 NumSameDeallocCpu: 0
38 DataTypeId: 0
39 TotalAccessDensity: 0
40 MinAccessDensity: 0
41 MaxAccessDensity: 0
42 TotalLifetimeAccessDensity: 0
43 MinLifetimeAccessDensity: 0
44 MaxLifetimeAccessDensity: 0
45 AccessHistogramSize: 0
46 AccessHistogram: 0
47 ...
48
49 //--- src.cpp
50 // CHECK-LABEL: define{{.*}} ptr @_Z3foov()
51 // DEFAULT: call {{.*}} ptr @_Znam12__hot_cold_t(i64 10, i8 -128)
52 // ALLOCTOKEN: call {{.*}} ptr @__alloc_token__Znam12__hot_cold_t(i64 10, i8 -128, i64 1538840549748785101){{.*}} !alloc_token
53 char *foo() {
54 return new char[10];
55 }
56
57 int main() {
58 char *a = foo();
59 delete[] a;
60 return 0;
61 }