This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add debug dump options
ClosedPublic

Authored by FarisRehman on Feb 15 2021, 8:09 AM.

Details

Summary

Add the following options:

  • -fdebug-dump-symbols
  • -fdebug-dump-parse-tree
  • -fdebug-dump-provenance

Summary of changes:

  • Add 3 new frontend actions: DebugDumpSymbolsAction, DebugDumpParseTreeAction and DebugDumpProvenanceAction
  • Add a unique pointer to the Semantics instance created in PrescanAndSemaAction
  • Move fatal semantic error reporting to its own method, FrontendActions#reportFatalSemanticErrors
  • Port most tests using -fdebug-dump-symbols and -fdebug-dump-parse-tree to the new driver if built, otherwise default to f18

Diff Detail

Event Timeline

FarisRehman created this revision.Feb 15 2021, 8:09 AM
FarisRehman requested review of this revision.Feb 15 2021, 8:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2021, 8:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
FarisRehman edited the summary of this revision. (Show Details)Feb 15 2021, 8:12 AM
FarisRehman added a project: Restricted Project.

Rebase off main

Rebase off main and update some comments.

FarisRehman edited the summary of this revision. (Show Details)Feb 16 2021, 2:24 AM

I think that this patch does a great job demonstrating the use of frontend actions and how _action_ compiler flags map to them. Given how Fortran::semantics::Semantics are defined and created, I think that adding _semantics_ as a member variable to PrescanAndSemaAction makes a lot of sense.

Btw, I also think that it would be worth exploring what Clang does. Ideally we'd have some Sema API that would be a member of CompilerInstance. However, that's outside the scope of this patch :)

Apart from one comment this looks good to me. Thank you for submitting this @FarisRehman !

flang/include/flang/Frontend/FrontendActions.h
56

Do we need to expose it? Shouldn't this be private?

FarisRehman added inline comments.Feb 16 2021, 8:15 AM
flang/include/flang/Frontend/FrontendActions.h
56

It will not compile if the variable is private as it needs to be referenced in the implementation of ExecuteAction, e.g. DebugDumpParseTreeAction::ExecuteAction()
It will compile if set to protected or public

FarisRehman marked an inline comment as done.

Make semantics_ private

Make semantics_ in PrescanAndSemaAction private, adding semantics() and setSemantics().

Summary of changes:

  • Add semantics() and setSemantics() to PrescanAndSemaAction
  • Update tests to use -fsyntax-only but specify it first so that the new driver ignores it as only the last action option is executed. f18 will still run as if -fsyntax-only is present.
flang/include/flang/Frontend/FrontendActions.h
56

Updated to use a public getter and setter

awarzynski accepted this revision.Feb 17 2021, 10:53 AM

This patch doesn't require the tests to be updated, does it? Also: https://reviews.llvm.org/D96870. So it looks these are unrelated changes. Could you remove them before merging?

Otherwise, LGTM. Thanks for working on this!

This revision is now accepted and ready to land.Feb 17 2021, 10:53 AM
FarisRehman added a comment.EditedFeb 17 2021, 11:12 AM

This patch doesn't require the tests to be updated, does it?

They do require updating as -fdebug-dump-symbol and -fdebug-dump-parse-tree are otherwise not tested by the new driver in this patch.

They do require updating as -fdebug-dump-symbol and -fdebug-dump-parse-tree are otherwise not tested by the new driver in this patch.

Apologies, I wasn't clear (realized after submitting). We need %f18 to be replaced with %flang_fc1, but we don't need -fsyntax-only, right?

We need %f18 to be replaced with %flang_fc1, but we don't need -fsyntax-only, right?

Makes sense thanks, I'll remove before committing.

This revision was landed with ongoing or failed builds.Feb 18 2021, 3:35 AM
This revision was automatically updated to reflect the committed changes.