[PATCH] D85473: [Clang] Add option to allow marking pass-by-value args as noalias.
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 22:36:25 PDT 2020
rjmccall added a comment.
Is it acceptable to leave this as a -cc1 option while we're pursuing this with the language committee? Do we have any intent to pursue this with the language committee?
================
Comment at: clang/include/clang/Basic/LangOptions.def:372
+LANGOPT(PassByValueIsNoAlias, 1, 0, "assumption that by-value parameters do "
+ "not alias any other values")
----------------
This should be a code-gen option, I think. I can't really imagine how this would affect language processing.
================
Comment at: clang/include/clang/Driver/Options.td:4287-4290
+def fpass_by_value_noalias: Flag<["-"], "fpass-by-value-noalias">,
+ HelpText<"Allows assuming no references to passed by value escape before "
+ "transferring execution to the called function. Note that this "
+ "does not hold for C++">;
----------------
rsmith wrote:
> This should be in `Group<f_Group>`.
The "Note" clause seems to muddy more than it clarifies. Maybe "has no effect on non-trivially-copyable classes in C++"? Or add proper documentation somewhere instead of trying to jam this into the help text.
================
Comment at: clang/lib/CodeGen/CGCall.cpp:2198
+ // reference to the underlying object. Mark it accordingly.
+ Attrs.addAttribute(llvm::Attribute::NoAlias);
+
----------------
This definitely can't be added unconditionally to all types; you need to rule out non-trivial C++ class types, as well as types with ObjC weak references.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85473/new/
https://reviews.llvm.org/D85473
More information about the cfe-commits
mailing list