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 -gdwarf-4 -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 -gdwarf-4 -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: [[INT_TYPE:![0-9]+]] = !DIBasicType(name: "int", 26 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1" 27 // DECLS-FOR-EXTERN-SAME: type: [[FN1_TYPE:![0-9]+]], 28 // DECLS-FOR-EXTERN: [[FN1_TYPE]] = !DISubroutineType(types: [[FN1_TYPES:![0-9]+]]) 29 // DECLS-FOR-EXTERN: [[FN1_TYPES]] = !{[[X_TYPE:![0-9]+]], 30 // DECLS-FOR-EXTERN: [[X_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "x", 31 // DECLS-FOR-EXTERN-SAME: baseType: [[INT_TYPE]]) 32 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp" 33 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name" 34 35 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1" 36 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp" 37 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name" 38 39 typedef int x; 40 extern x fn1(int a, int b); 41 extern int memcmp(const void *s1, const void *s2, unsigned long n); 42 extern void __some_reserved_name(void); 43 44 int fn2 (int *src, int *dst) { 45 int x = 4, y = 5; 46 int res = fn1(x, y); 47 int res2 = memcmp(dst, src, res); 48 __some_reserved_name(); 49 return res + res2; 50 } 51 52