[cfe-dev] [RFC] automatic variable initialization

JF Bastien via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 29 10:01:03 PST 2018



> On Nov 29, 2018, at 7:25 AM, via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
>> Suggested compromise technique to at least get an initial set of numbers:
>> 
>> 1) Require a special, long, ugly flag name.
>> 2) Make it a CC1 flag, requiring -Xclang ... to use.
>> 3) Emit a warning by default (that cannot be suppressed with a -Wno-...
>> flag) when this flag is enabled.
> 
> And immune to -Werror I think?

Right, that’s a requirement.


>> 4) Commit to never including this flag in any upstream release. Either we
>> remove it before the next release branches or we revert it on the branch.
> 
> Add it to the release-manager's checklist so it doesn't slip through.

Do we have a macro that’s turned on for official clang releases?


> (I don't know if my users would be interested in this, but I have been
> through the ugly-option-name dance before.)
> --paulr
> 
>> Most of the folks we're hoping to get performance data with are willing to
>> use a not-yet-released build of Clang. They won't have to actually patch
>> it in any way. They will have strong reminders to not deploy this in any
>> way due to the warning.
>> 
>> Thoughts?

I’m not sure this works as I have things set up right now. Here’s how you use my patch at the moment:

  1. On the command-line:

    -ftrivial-auto-var-init=uninitialized (the default)
    -ftrivial-auto-var-init=pattern
    -ftrivial-auto-var-init=zero

  2. Using an attribute:

    int dont_initialize_me __attribute((trivial_auto_init("uninitialized")));
    int zero_me __attribute((trivial_auto_init("zero")));
    int pattern_me __attribute((trivial_auto_init("pattern")));

You’re proposing to change the “zero” command-line option only? Attribute as well?

Long term I think we want to have a variety of choices, as you’ve proposed earlier in the thread (e.g. “load-pattern” and “random-pattern” are examples). With the current setup (uninitialized/pattern/zero) I can change the flags to be separate (and then your -Xclang thing works), but it’s a mismatch with the long-term approach.

As flags / attributes are set up right now I can for sure rename “zero”.
It’s easy to add the warning (both if the command-line flag is use, and if the attribute is used).
I can also un-document “zero”, while also renaming it.
I can add a *separate* -Xclang option which is required to be set if the renamed “zero” is used. That would line up with your suggestion.

WDYT?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181129/6d276ba3/attachment.html>


More information about the cfe-dev mailing list