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: !{{[0-9]+}}
25 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
26 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
27 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
28 
29 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1"
30 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
31 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
32 
33 extern int fn1(int a, int b);
34 extern int memcmp(const void *s1, const void *s2, unsigned long n);
35 extern void __some_reserved_name(void);
36 
37 int fn2 (int *src, int *dst) {
38   int x = 4, y = 5;
39   int res = fn1(x, y);
40   int res2 = memcmp(dst, src, res);
41   __some_reserved_name();
42   return res + res2;
43 }
44 
45