blob: c6216b3ff85b27cbda2b1a84f4f9629ca978d113 [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 -g -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
Adrian Prantl5ca58a02013-03-12 21:40:00 +00002
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.
Adrian Prantl00df5ea2013-03-12 20:43:25 +00006
7#define INLINE inline __attribute__((always_inline))
8
Stephen Hines6bcf27b2014-05-29 04:14:42 -07009int i;
10
11INLINE void sum(int a, int b) {
12 i = a + b;
Adrian Prantl00df5ea2013-03-12 20:43:25 +000013}
14
Stephen Hines6bcf27b2014-05-29 04:14:42 -070015void noinline(int x, int y) {
16 i = x + y;
Adrian Prantl00df5ea2013-03-12 20:43:25 +000017}
18
Stephen Hines6bcf27b2014-05-29 04:14:42 -070019#define CALLS sum(9, 10), sum(11, 12)
20
21inline void inlsum(int t, int u) {
22 i = t + u;
Adrian Prantl00df5ea2013-03-12 20:43:25 +000023}
24
Stephen Hines6bcf27b2014-05-29 04:14:42 -070025int main() {
26 sum(1, 2), sum(3, 4);
27 noinline(5, 6), noinline(7, 8);
28 CALLS;
29 inlsum(13, 14), inlsum(15, 16);
Adrian Prantl00df5ea2013-03-12 20:43:25 +000030}
31
Stephen Hines6bcf27b2014-05-29 04:14:42 -070032// CHECK-LABEL: @main
33// CHECK: = add {{.*}} !dbg [[FIRST_INLINE:![0-9]*]]
34// CHECK: = add {{.*}} !dbg [[SECOND_INLINE:![0-9]*]]
Adrian Prantl00df5ea2013-03-12 20:43:25 +000035
Stephen Hines6bcf27b2014-05-29 04:14:42 -070036// 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 5, i32 6), !dbg [[NOINLINE:![0-9]*]]
39// CHECK: call {{.*}}noinline{{.*}}(i32 7, i32 8), !dbg [[NOINLINE]]
Adrian Prantl00df5ea2013-03-12 20:43:25 +000040
Stephen Hines6bcf27b2014-05-29 04:14:42 -070041// 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]]
Adrian Prantl00df5ea2013-03-12 20:43:25 +000049
Stephen Hines6bcf27b2014-05-29 04:14:42 -070050// 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 13, i32 14), !dbg [[INL_FIRST:![0-9]*]]
54// CHECK: call {{.*}}inlsum{{.*}}(i32 15, i32 16), !dbg [[INL_SECOND:![0-9]*]]
Adrian Prantl6b6a9b32013-03-15 17:09:05 +000055
Stephen Hines6bcf27b2014-05-29 04:14:42 -070056// [[FIRST_INLINE]] =
57// [[SECOND_INLINE]] =
Adrian Prantl00df5ea2013-03-12 20:43:25 +000058
Stephen Hines6bcf27b2014-05-29 04:14:42 -070059// 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]] =