1*9880d681SAndroid Build Coastguard Worker // RUN: llvm-dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/dead-stripped -o - | llvm-dwarfdump - -debug-dump=info | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker // The test was compiled with:
4*9880d681SAndroid Build Coastguard Worker // clang++ -O2 -g -c dead-strip.cpp -o 1.o
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker // The goal of the test is to exercise dsymutil's behavior in presence of
7*9880d681SAndroid Build Coastguard Worker // functions/variables that have been dead-stripped by the linker but
8*9880d681SAndroid Build Coastguard Worker // that are still present in the linked debug info (in this case because
9*9880d681SAndroid Build Coastguard Worker // they have been DW_TAG_import'd in another namespace).
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker // Everything in the N namespace bellow doesn't have a debug map entry, and
12*9880d681SAndroid Build Coastguard Worker // thus is considered dead (::foo() has a debug map entry, otherwse dsymutil
13*9880d681SAndroid Build Coastguard Worker // would just drop the CU altogether).
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker namespace N {
16*9880d681SAndroid Build Coastguard Worker int blah = 42;
17*9880d681SAndroid Build Coastguard Worker // This is actually a dsymutil-classic bug that we reproduced
18*9880d681SAndroid Build Coastguard Worker // CHECK: DW_TAG_variable
19*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_TAG
20*9880d681SAndroid Build Coastguard Worker // CHECK: DW_AT_location
21*9880d681SAndroid Build Coastguard Worker
foo()22*9880d681SAndroid Build Coastguard Worker __attribute__((always_inline)) int foo() { return blah; }
23*9880d681SAndroid Build Coastguard Worker // CHECK: DW_TAG_subprogram
24*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_low_pc
25*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_high_pc
26*9880d681SAndroid Build Coastguard Worker // CHECK: DW_AT_frame_base
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker // CHECK: DW_TAG_subprogram
29*9880d681SAndroid Build Coastguard Worker
bar(unsigned i)30*9880d681SAndroid Build Coastguard Worker int bar(unsigned i) {
31*9880d681SAndroid Build Coastguard Worker int val = foo();
32*9880d681SAndroid Build Coastguard Worker if (i)
33*9880d681SAndroid Build Coastguard Worker return val + bar(i-1);
34*9880d681SAndroid Build Coastguard Worker return foo();
35*9880d681SAndroid Build Coastguard Worker }
36*9880d681SAndroid Build Coastguard Worker // CHECK: DW_TAG_subprogram
37*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_low_pc
38*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_high_pc
39*9880d681SAndroid Build Coastguard Worker // CHECK: DW_AT_frame_base
40*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_location
41*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_low_pc
42*9880d681SAndroid Build Coastguard Worker // CHECK-NOT: DW_AT_high_pc
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker }
45*9880d681SAndroid Build Coastguard Worker // CHECK: TAG_imported_module
46*9880d681SAndroid Build Coastguard Worker using namespace N;
47*9880d681SAndroid Build Coastguard Worker
foo()48*9880d681SAndroid Build Coastguard Worker void foo() {}
49