1 // When entry values are emitted, expect a subprogram for extern decls so that
2 // the dwarf generator can describe call site parameters at extern call sites.
3 //
4 // Initial implementation relied on the 'retainedTypes:' from the corresponding
5 // DICompileUnit, so we also ensure that we do not store the extern declaration
6 // subprogram into the 'retainedTypes:'.
7 //
8 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
9 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
10 
11 // Similarly, when the debugger tuning is gdb, expect a subprogram for extern
12 // decls so that the dwarf generator can describe information needed for tail
13 // call frame reconstrution.
14 //
15 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s -o - \
16 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
17 //
18 // Do not emit a subprogram for extern decls when entry values are disabled and
19 // the tuning is not set to gdb.
20 //
21 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
22 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
23 
24 // DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]]
25 // DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
26 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
27 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
28 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
29 
30 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1"
31 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
32 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
33 
34 extern int fn1(int a, int b);
35 extern int memcmp(const void *s1, const void *s2, unsigned long n);
36 extern void __some_reserved_name(void);
37 
38 int fn2 (int *src, int *dst) {
39   int x = 4, y = 5;
40   int res = fn1(x, y);
41   int res2 = memcmp(dst, src, res);
42   __some_reserved_name();
43   return res + res2;
44 }
45 
46