Debian Codegraph @

clang/test/CodeGen/distributed-thin-lto/memprof-pgho.cpp

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