2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
7 /* Test that dwarf info for local variables is preserved after linking.
9 * We have checks encoded as "CHECK: regex", and the regexes must be
10 * matched in-order in the disassembled file. An external tool
11 * "file-check" will do the checks provided this source file and the binary.
16 extern int bar(int x) __attribute__((noinline));
18 __attribute__((noinline)) int foo(int dwarf_test_param) {
19 /* CHECK: DW_TAG_formal_parameter */
20 /* CHECK: DW_AT_name.* dwarf_test_param */
21 /* CHECK: DW_AT_decl_line.* 18 */
22 return bar(dwarf_test_param);
25 int main(int argc, char* argv[]) {
27 /* CHECK: DW_TAG_variable */
28 /* CHECK: DW_AT_name.* dwarf_test_local */
29 /* CHECK: DW_AT_decl_line.* 26 */
31 /* Try to trick the optimizer to preserve dwarf_test_local. */
33 /* This branch should be taken. */
34 dwarf_test_local = 55;
35 } else if (argc == 54) {
36 dwarf_test_local = atoi(argv[1]);
38 dwarf_test_local = -1;
42 /* This branch should be taken. */
43 return foo(dwarf_test_local);