xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/debug-info-same-line.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1 // RUN: %clang_cc1 -g -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
2 
3 // Make sure that clang outputs distinct debug info for a function
4 // that is inlined twice on the same line. Otherwise it would appear
5 // as if the function was only inlined once.
6 
7 #define INLINE inline __attribute__((always_inline))
8 
9 int i;
10 
sum(int a,int b)11 INLINE void sum(int a, int b) {
12   i = a + b;
13 }
14 
noinline(int x,int y)15 void noinline(int x, int y) {
16   i = x + y;
17 }
18 
19 #define CALLS sum(9, 10), sum(11, 12)
20 
inlsum(int t,int u)21 inline void inlsum(int t, int u) {
22   i = t + u;
23 }
24 
main()25 int main() {
26   sum(1, 2), sum(3, 4);
27   noinline(5, 6), noinline(7, 8);
28   CALLS;
29   inlsum(13, 14), inlsum(15, 16);
30 }
31 
32 // CHECK-LABEL: @main
33 // CHECK: = add {{.*}} !dbg [[FIRST_INLINE:![0-9]*]]
34 // CHECK: = add {{.*}} !dbg [[SECOND_INLINE:![0-9]*]]
35 
36 // Check that we don't give column information (and thus end up with distinct
37 // line entries) for two non-inlined calls on the same line.
38 // CHECK: call {{.*}}noinline{{.*}}({{i32[ ]?[a-z]*}} 5, {{i32[ ]?[a-z]*}} 6), !dbg [[NOINLINE:![0-9]*]]
39 // CHECK: call {{.*}}noinline{{.*}}({{i32[ ]?[a-z]*}} 7, {{i32[ ]?[a-z]*}} 8), !dbg [[NOINLINE]]
40 
41 // FIXME: These should be separate locations but because the two calls have the
42 // same line /and/ column, they get coalesced into a single inlined call by
43 // accident. We need discriminators or some other changes to LLVM to cope with
44 // this. (this is, unfortunately, an LLVM test disguised as a Clang test - since
45 // inlining is forced to happen here). It's possible this could be fixed in
46 // Clang, but I doubt it'll be the right place for the fix.
47 // CHECK: = add {{.*}} !dbg [[FIRST_MACRO_INLINE:![0-9]*]]
48 // CHECK: = add {{.*}} !dbg [[FIRST_MACRO_INLINE]]
49 
50 // Even if the functions are marked inline but do not get inlined, they
51 // shouldn't use column information, and thus should be at the same debug
52 // location.
53 // CHECK: call {{.*}}inlsum{{.*}}({{i32[ ]?[a-z]*}} 13, {{i32[ ]?[a-z]*}} 14), !dbg [[INL_FIRST:![0-9]*]]
54 // CHECK: call {{.*}}inlsum{{.*}}({{i32[ ]?[a-z]*}} 15, {{i32[ ]?[a-z]*}} 16), !dbg [[INL_SECOND:![0-9]*]]
55 
56 // [[FIRST_INLINE]] =
57 // [[SECOND_INLINE]] =
58 
59 // FIXME: These should be the same location since the functions appear on the
60 // same line and were not inlined - they needlessly have column information
61 // intended to disambiguate inlined calls, which is going to confuse GDB as it
62 // doesn't cope well with column information.
63 // [[INL_FIRST]] =
64 // [[INL_SECOND]] =
65