[all-commits] [llvm/llvm-project] a25e4a: [clang][cli] Store additional optimization remarks...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Thu Feb 25 02:03:26 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a25e4a6da3fe43f631782b1668e0ac023f6b5848
      https://github.com/llvm/llvm-project/commit/a25e4a6da3fe43f631782b1668e0ac023f6b5848
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    M clang/include/clang/Basic/CodeGenOptions.h
    M clang/lib/CodeGen/CodeGenAction.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp

  Log Message:
  -----------
  [clang][cli] Store additional optimization remarks info

After a revision of D96274 changed `DiagnosticOptions` to not store all remark arguments **as-written**, it is no longer possible to reconstruct the arguments accurately from the class.

This is caused by the fact that for `-Rpass=regexp` and friends, `DiagnosticOptions` store only the group name `pass` and not `regexp`. This is the same representation used for the plain `-Rpass` argument.

Note that each argument must be generated exactly once in `CompilerInvocation::generateCC1CommandLine`, otherwise each subsequent call would produce more arguments than the previous one. Currently this works out because of the way `RoundTrip` splits the responsibilities for certain arguments based on what arguments were queried during parsing. However, this invariant breaks when we move to single round-trip for the whole `CompilerInvocation`.

This patch ensures that for one `-Rpass=regexp` argument, we don't generate two arguments (`-Rpass` from `DiagnosticOptions` and `-Rpass=regexp` from `CodeGenOptions`) by shifting the responsibility for handling both cases to `CodeGenOptions`. To distinguish between the cases correctly, additional information is stored in `CodeGenOptions`.

The `CodeGenOptions` parser of `-Rpass[=regexp]` arguments also looks at `-Rno-pass` and `-R[no-]everything`, which is necessary for generating the correct argument regardless of the ordering of `CodeGenOptions`/`DiagnosticOptions` parsing/generation.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D96847


  Commit: d748908fa02b11c7840a7f03c7a52223126bdba9
      https://github.com/llvm/llvm-project/commit/d748908fa02b11c7840a7f03c7a52223126bdba9
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Frontend/CompilerInvocation.h
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/test/Frontend/round-trip-cc1-args.c

  Log Message:
  -----------
  [clang][cli] Round-trip the whole CompilerInvocation

Finally, this patch moves from round-tripping one `CompilerInvocation` at a time to round-tripping the invocation as a whole.

This patch includes only the code required to make round-tripping the whole invocation work. More cleanups will be done in a follow-up patch.

Depends on D96847, D97041 & D97042.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D96280


Compare: https://github.com/llvm/llvm-project/compare/30cb9c03b53e...d748908fa02b


More information about the All-commits mailing list