[PATCH] D103928: [IR] make -warn-frame-size into a module attr

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 9 16:29:42 PDT 2021


rsmith added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:2575-2581
 // These "special" warning flags are effectively processed as f_Group flags by the driver:
 // Just silence warnings about -Wlarger-than for now.
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, Group<clang_ignored_f_Group>;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias<Wlarger_than_EQ>;
-def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group<f_Group>, Flags<[NoXarchOption]>;
+def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">,
+  Group<f_Group>, Flags<[NoXarchOption,CC1Option]>,
+  MarshallingInfoInt<CodeGenOpts<"WarnStackSize">, "UINT_MAX">;
----------------
nickdesaulniers wrote:
> @rsmith I wasn't super sure about this hunk of the diff.  Should I not be reusing the same flag between the Frontend and the Driver? (The Driver comes after the Frontend, IIUC? Is that right?)
(The driver comes before the frontend: the driver is the user-facing GCC-compatible `clang` binary, and the frontend is the `-cc1` interface.)

What we do in other cases is to translate the driver-level (user-facing) warning flag into multiple frontend flags:

* The driver-level flag `-Wwrite-strings` (in C) gets mapped into the frontend-level flags `-Wwrite-strings -fconst-strings`, where `-Wwrite-strings` only controls whether the warning is shown, and `-fconst-strings` only controls whether string literals have type `char[N]` or `const char[N]`.
* The driver-level flag `-Wdeprecated` (in C++) gets mapped into the frontend-level flags `-Wdeprecated -fdeprecated-macro`, where `-Wdeprecated` only controls whether the warning is shown, and `-fdeprecated-macro` only controls whether `__DEPRECATED` is implicitly defined by the preprocessor.

So I think the expected strategy here would probably be that the driver-level flag `-Wframe-larger-than=N` would get mapped into the frontend-level flags `-Wframe-larger-than -fsomething=N`, where `-Wframe-larger-than` only controls whether the warning is shown, and `-fsomething=N` sets the level of stack usage at which the backend triggers the warning.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103928/new/

https://reviews.llvm.org/D103928



More information about the cfe-commits mailing list