blob: 965a538f847219880e9e42c3b80f843ddc142b33 [file] [log] [blame]
Hans Wennborgc9bd88e2014-01-14 19:35:09 +00001// RUN: %clang_cc1 -g -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
Adrian Prantl06e5e152013-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 Prantlc7822422013-03-12 20:43:25 +00006
7#define INLINE inline __attribute__((always_inline))
8
David Blaikie9c8821b2014-05-10 02:44:57 +00009int i;
10
11INLINE void sum(int a, int b) {
12 i = a + b;
Adrian Prantlc7822422013-03-12 20:43:25 +000013}
14
David Blaikie9c8821b2014-05-10 02:44:57 +000015void noinline(int x, int y) {
16 i = x + y;
Adrian Prantlc7822422013-03-12 20:43:25 +000017}
18
David Blaikie9c8821b2014-05-10 02:44:57 +000019#define CALLS sum(9, 10), sum(11, 12)
20
21inline void inlsum(int t, int u) {
22 i = t + u;
Adrian Prantlc7822422013-03-12 20:43:25 +000023}
24
David Blaikie9c8821b2014-05-10 02:44:57 +000025int 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 Prantlc7822422013-03-12 20:43:25 +000030}
31
David Blaikie9c8821b2014-05-10 02:44:57 +000032// CHECK-LABEL: @main
33// CHECK: = add {{.*}} !dbg [[FIRST_INLINE:![0-9]*]]
34// CHECK: = add {{.*}} !dbg [[SECOND_INLINE:![0-9]*]]
Adrian Prantlc7822422013-03-12 20:43:25 +000035
David Blaikie9c8821b2014-05-10 02:44:57 +000036// 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.
Will Schmidt22b065c2014-06-02 21:47:14 +000038// 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]]
Adrian Prantlc7822422013-03-12 20:43:25 +000040
David Blaikie9c8821b2014-05-10 02:44:57 +000041// 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 Prantlc7822422013-03-12 20:43:25 +000049
David Blaikie9c8821b2014-05-10 02:44:57 +000050// 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.
Will Schmidt22b065c2014-06-02 21:47:14 +000053// 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]*]]
Adrian Prantl5acf8a32013-03-15 17:09:05 +000055
David Blaikie9c8821b2014-05-10 02:44:57 +000056// [[FIRST_INLINE]] =
57// [[SECOND_INLINE]] =
Adrian Prantlc7822422013-03-12 20:43:25 +000058
David Blaikie9c8821b2014-05-10 02:44:57 +000059// 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]] =