xref: /llvm-project/llvm/test/tools/dsymutil/X86/dead-stripped.cpp (revision b61ac4a88f934ab5c02ee2a4957fb1b9943e7a5d)
1 // RUN: dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/dead-stripped -o - | llvm-dwarfdump - --debug-info | FileCheck %s --implicit-check-not "{{DW_AT_low_pc|DW_AT_high_pc|DW_AT_location|DW_TAG|NULL}}"
2 
3 // The test was compiled with:
4 // clang++ -O2 -g -c dead-strip.cpp -o 1.o
5 
6 // The goal of the test is to exercise dsymutil's behavior in presence of
7 // functions/variables that have been dead-stripped by the linker but
8 // that are still present in the linked debug info (in this case because
9 // they have been DW_TAG_import'd in another namespace).
10 
11 // Everything in the N namespace below doesn't have a debug map entry, and
12 // thus is considered dead (::foo() has a debug map entry, otherwise dsymutil
13 // would just drop the CU altogether).
14 
15 // CHECK: DW_TAG_compile_unit
16 // CHECK:   DW_AT_low_pc
17 // CHECK:   DW_AT_high_pc
18 // CHECK:   DW_TAG_namespace
19 namespace N {
20 int blah = 42;
21 // CHECK: DW_TAG_variable
22 // CHECK-NOT: DW_AT_location
23 
foo()24 __attribute__((always_inline)) int foo() { return blah; }
25 // CHECK: DW_TAG_subprogram
26 // CHECK-NOT:  DW_AT_frame_base
27 
28 // CHECK: DW_TAG_subprogram
29 
bar(unsigned i)30 int bar(unsigned i) {
31 	int val = foo();
32 	if (i)
33 		return val + bar(i-1);
34 	return foo();
35 }
36 // CHECK: DW_TAG_subprogram
37 // CHECK-NOT:  DW_AT_frame_base
38 // CHECK:   DW_TAG_formal_parameter
39 // CHECK:   DW_TAG_variable
40 // CHECK:   DW_TAG_inlined_subroutine
41 // CHECK:   NULL
42 // CHECK: NULL
43 }
44 // CHECK: DW_TAG_base_type
45 // CHECK: DW_TAG_imported_module
46 // CHECK: DW_TAG_subprogram
47 // CHECK:   DW_AT_low_pc
48 // CHECK:   DW_AT_high_pc
49 // CHECK: DW_TAG_base_type
50 // CHECK: NULL
51 
52 using namespace N;
53 
foo()54 void foo() {}
55