Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebugInfo] Support for DWARF 4/5 and fix of issues related to -gdwarf-X options #92

Merged
merged 3 commits into from Sep 20, 2020

Conversation

alokkrsharma
Copy link

Current pull request is merge of #89 #90 and #91 (all approved) on release_90 branch.

It has 3 commits to

  • Support DWARF version 4 and 5 in driver.
  • Fix the issue when multiple -gdwarf-X options are present in command line.
  • Setting 4 as default DWARF version when explicitly not mentioned with -gdwarf-N but -g is present.

Note: this patch would work with Flang patch flang-compiler/flang#863

@alokkrsharma
Copy link
Author

Hi @gklimowicz
Please let me know whether it is as per your expectation.
Regards,
Alok

Summary:
  FLANG driver doesnt pass -gdwarf-4/5 to flang1 in form of xbits,
while it passes for -gdwarf-2/3
   -gdwarf-2 => -x 120 0x200
   -gdwarf-3 => -x 120 0x4000

Due to this -gdwarf-5 is never honored and default option -gdwarf-4
is taken.
    # flang -gdwarf-5 test.f90
    # llvm-dwarfdump a.out | grep version
    0x00000000: Compile Unit: length = 0x0000008e version = 0x0004

  Now 0x1000000/0x2000000 will be passed for -gdwarf-4/5
   -gdwarf-4 => -x 120 0x1000000
   -gdwarf-5 => -x 120 0x2000000

Testing:
  - GNU gdb fortran testsuite
  - check-llvm
  - check-debuginfo
…entioned

 Summary:
When multiple -g/-gdwarfN options are passed together at compile time,
flang chooses the least one. Clang/gfortran etc choose the last one.

-gdwarf-5 -gdwarf-3 => flang chooses 5 while clang/gfortran choose 3
-gdwarf-5 -g => flang choses the default while clang/gfortran choose 5

  Testing:
- check-llvm
- check-debuginfo
Currently flang dumps dwarf version 2 for -g and 4 for absence of -g

-------------------------
$ flang my.f90
$ llvm-dwarfdump a.out | grep version
0x00000000: Compile Unit: length = 0x0000003d version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000041)

$ flang -g my.f90
$ llvm-dwarfdump a.out | grep version
0x00000000: Compile Unit: length = 0x00000047 version = 0x0002 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000004b)
-------------------------

It should be 4 for -g as it is the case with clang.
Copy link

@gklimowicz gklimowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I ran the tests on OpenPOWER and got the results I expected to see. Thank you @alokkrsharma

Copy link
Collaborator

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Two minor comments.

options::OPT_gdwarf_5);

if (GArg || GDwarfArg) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Empty line? Does it match the style in the rest of this file?

CommonCmdArgs.push_back("120");
CommonCmdArgs.push_back("0x4000");
if (!GDwarfArg) // -g without -gdwarf-X produces default (DWARFv4)
CommonCmdArgs.push_back("0x1000000");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can GetDefaultDwarfVersion be used to set the default dwarf version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants