This is an archive of the discontinued LLVM Phabricator instance.

[flang][f18] Make -fdebug-dump-{symbols|parse-tree} imply -fsyntax-only
ClosedPublic

Authored by awarzynski on Feb 11 2021, 10:42 AM.

Details

Summary

The following _action_ options are always used with -fsyntax-only
(also an _action_ option):

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

This patch makes the above options imply -fsyntax-only.

From the perspective of f18 this change saves typing and is otherwise
a non-functional change. But it will simplify things in the new driver,
flang-new, in which only the last action option is taken into account
and executed. In other words, the following would only run
-fsyntax-only:

flang-new -fdebug-dump-symbols -fsyntax-only <input>

whereas this would only run -fdebug-dump-symbols:

flang-new -fsyntax-only -fdebug-dump-symbols <input>

Diff Detail

Event Timeline

awarzynski requested review of this revision.Feb 11 2021, 10:42 AM
awarzynski created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 11 2021, 10:42 AM
FarisRehman accepted this revision.EditedFeb 15 2021, 4:36 AM

This patch makes sense to me as the behaviour of the new driver is similar to clang in that only the last action-related option is run, e.g:

  • Only -emit-llvm is run in: clang -cc1 -ast-dump -emit-llvm file.c
  • Only -ast-dump is run in: clang -cc1 -emit-llvm -ast-dump file.c

This change will mean -fsyntax-only does not need to be specified when running -fdebug-dump-parse-tree or -fdebug-dump-symbols as it will always be run when either one of these action-related options are present.
LGTM!

This revision is now accepted and ready to land.Feb 15 2021, 4:36 AM

These are orthogonal concepts, and I occasionally will dump symbols with f18 without using -fsyntax-only.

Apologies for disrupting your workflow. Just to double check - you want to use -fdebug-dump-symbols and then have f18 call the external compiler?

I will upload a patch that restores the original behavior in f18.

Apologies for disrupting your workflow. Just to double check - you want to use -fdebug-dump-symbols and then have f18 call the external compiler?

I will upload a patch that restores the original behavior in f18.

I don't think that you can do that without also reverting changes to tests, and we probably don't want to do that.

Apologies for disrupting your workflow. Just to double check - you want to use -fdebug-dump-symbols and then have f18 call the external compiler?

I will upload a patch that restores the original behavior in f18.

I don't think that you can do that without also reverting changes to tests, and we probably don't want to do that.

That's true, but we can update the tests to use: -fsyntax-only -fdebug-dump-parse-tree:

  • this restores the original behavior for f18
  • the new driver will _ignore_ -fsyntax-only and run -fdebug-dump-parse-tree only (so this would be fine for flang-new as well)

Originally some tests had -fdebug-dump-parse-tree -fsyntax-only and that order is problematic for the new driver (it only respects the last _action_).

Apologies for disrupting your workflow. Just to double check - you want to use -fdebug-dump-symbols and then have f18 call the external compiler?

I will upload a patch that restores the original behavior in f18.

I don't think that you can do that without also reverting changes to tests, and we probably don't want to do that.

That's true, but we can update the tests to use: -fsyntax-only -fdebug-dump-parse-tree:

  • this restores the original behavior for f18
  • the new driver will _ignore_ -fsyntax-only and run -fdebug-dump-parse-tree only (so this would be fine for flang-new as well)

Originally some tests had -fdebug-dump-parse-tree -fsyntax-only and that order is problematic for the new driver (it only respects the last _action_).

What if a compiler developer wants multiple dumps?

What if a compiler developer wants multiple dumps?

This is tricky. flang-new -cc1 models clang -cc1 in this respect and runs one action at a time. Diverging from this design would be challenging because then the driver would have to:

  • schedule the actions (and keep track of them)
  • parse options for every action separately
  • resolve potential conflicts with options (e.g. one option is fine with one of the requested actions, but causes a driver/compilation error for the other)

Alternatively, we could make -fdebug-dump-parse-tree and -fdebug-dump-symbols non-action flags in flang-new. This wouldn't fit nicely into the model implemented in libclangDriver where compiler flags/options are split into:

  • action flags
  • set-up/config/feature flags.

I've reverted this change in https://reviews.llvm.org/D96870. Moving forward, I would like to keep the current approach in flang-new -fc1. This may mean some inconsistencies with f18 in terms of user-experience, but the alternative would be costly to implement.