This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add options for unparsing
ClosedPublic

Authored by awarzynski on Feb 11 2021, 2:59 AM.

Details

Summary

This patch adds the following compiler frontend driver options:

  • -fdebug-unparse (f18 spelling: -funparse)
  • -fdebug-unparse-with-symbols (f18 spelling: -funparse-with-symbols)

The new driver will only accept the new spelling. f18 will accept both
the original and the new spelling.

A new base class for frontend actions is added: PrescanAndSemaAction.
This is added to reduce code duplication that otherwise these new
options would lead to. Implementation from

  • ParseSyntaxOnlyAction::ExecutionAction

is moved to:

  • PrescanAndSemaAction::BeginSourceFileAction

This implementation is now shared between:

  • PrescanAndSemaAction
  • ParseSyntaxOnlyAction
  • DebugUnparseAction
  • DebugUnparseWithSymbolsAction

All tests that don't require other yet unimplemented options are
updated. This way flang-new -fc1 is used instead of f18 when
FLANG_BUILD_NEW_DRIVER is set to On. In order to facilitate this,
%flang_fc1 is added in the LIT configuration (lit.cfg.py).

asFortran from f18.cpp is duplicated as getBasicAsFortran in
FrontendOptions.cpp. At this stage it's hard to find a good place to
share this method. I suggest that we revisit this once a switch from
f18 to flang-new is complete.

Diff Detail

Event Timeline

awarzynski created this revision.Feb 11 2021, 2:59 AM
awarzynski requested review of this revision.Feb 11 2021, 2:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 11 2021, 2:59 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tskeith added inline comments.Feb 11 2021, 8:09 AM
flang/tools/f18/f18.cpp
543

This should be "-fdebug-unparse" (with a hyphen). That may be why all those tests are failing.

Fix typo in f18.cpp

flang/tools/f18/f18.cpp
543

Fixed, thank you!

FarisRehman added a comment.EditedFeb 15 2021, 5:52 AM

Thanks for working on this @awarzynski
Do you know what the use of GetActionKindName in FrontendOptions.h is, as it is currently not being called anywhere and whilst this patch currently does not update that method with the 2 new cases, even if it did no change would be visible.
Other than that, looks good to me!

flang/test/lit.cfg.py
87

[nit] Is there a reason to have this as a separate if-else instead of merging with the existing if-else

Updated lit.cfg.py

Do you know what the use of GetActionKindName in FrontendOptions.h is, as it is currently not being called anywhere and whilst this patch currently does not update that method with the 2 new cases, even if it did no change would be visible.

I'm not sure why this method is there TBH :) Perhaps @CarolineConcatto would know? I suspect that C&P error. I suggest removing it in a separate NFC patch. Thank you for pointing that out!

flang/test/lit.cfg.py
87

Good point, updated!

This revision is now accepted and ready to land.Feb 15 2021, 8:14 AM
This revision was landed with ongoing or failed builds.Feb 16 2021, 1:33 AM
This revision was automatically updated to reflect the committed changes.