xref: /aosp_15_r20/external/clang/test/Frontend/profile-sample-use-loc-tracking.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // This file tests that -fprofile-sample-use enables location tracking
2*67e74705SXin Li // generation in the same way that -Rpass does. The sample profiler needs
3*67e74705SXin Li // to associate line locations in the profile to the code, so it needs the
4*67e74705SXin Li // frontend to emit source location annotations.
5*67e74705SXin Li 
6*67e74705SXin Li // RUN: %clang_cc1 %s -fprofile-sample-use=%S/Inputs/profile-sample-use-loc-tracking.prof -emit-llvm -o - 2>/dev/null | FileCheck %s
7*67e74705SXin Li 
8*67e74705SXin Li // -fprofile-sample-use should produce source location annotations, exclusively
9*67e74705SXin Li // (just like -gmlt).
10*67e74705SXin Li // CHECK: , !dbg !
11*67e74705SXin Li // CHECK-NOT: DW_TAG_base_type
12*67e74705SXin Li 
13*67e74705SXin Li // The CU should be marked NoDebug (to prevent writing debug info to
14*67e74705SXin Li // the final output).
15*67e74705SXin Li // CHECK: !llvm.dbg.cu = !{![[CU:.*]]}
16*67e74705SXin Li // CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug
17*67e74705SXin Li 
bar(int j)18*67e74705SXin Li int bar(int j) {
19*67e74705SXin Li   return (j + j - 2) * (j - 2) * j;
20*67e74705SXin Li }
21