Hans Wennborg | c9bd88e | 2014-01-14 19:35:09 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -g -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s |
Adrian Prantl | 06e5e15 | 2013-03-12 21:40:00 +0000 | [diff] [blame] | 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. |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 6 | |
| 7 | #define INLINE inline __attribute__((always_inline)) |
| 8 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 9 | int i; |
| 10 | |
| 11 | INLINE void sum(int a, int b) { |
| 12 | i = a + b; |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 13 | } |
| 14 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 15 | void noinline(int x, int y) { |
| 16 | i = x + y; |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 17 | } |
| 18 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 19 | #define CALLS sum(9, 10), sum(11, 12) |
| 20 | |
| 21 | inline void inlsum(int t, int u) { |
| 22 | i = t + u; |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 23 | } |
| 24 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 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); |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 30 | } |
| 31 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 32 | // CHECK-LABEL: @main |
| 33 | // CHECK: = add {{.*}} !dbg [[FIRST_INLINE:![0-9]*]] |
| 34 | // CHECK: = add {{.*}} !dbg [[SECOND_INLINE:![0-9]*]] |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 35 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 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. |
Will Schmidt | 22b065c | 2014-06-02 21:47:14 +0000 | [diff] [blame] | 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]] |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 40 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 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]] |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 49 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 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. |
Will Schmidt | 22b065c | 2014-06-02 21:47:14 +0000 | [diff] [blame] | 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]*]] |
Adrian Prantl | 5acf8a3 | 2013-03-15 17:09:05 +0000 | [diff] [blame] | 55 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 56 | // [[FIRST_INLINE]] = |
| 57 | // [[SECOND_INLINE]] = |
Adrian Prantl | c782242 | 2013-03-12 20:43:25 +0000 | [diff] [blame] | 58 | |
David Blaikie | 9c8821b | 2014-05-10 02:44:57 +0000 | [diff] [blame] | 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]] = |