Add GCC-compatible flags -fprofile-generate and -fprofile-use

Diego Novillo dnovillo at google.com
Tue Jun 30 12:34:18 PDT 2015


On Mon, Jun 29, 2015 at 5:09 PM, Justin Bogner <mail at justinbogner.com> wrote:
> Diego Novillo <dnovillo at google.com> writes:
>>
>> +  ``LLVM_PROFILE_FILE`` can be used to alter the directory and filename for the
>> +  profile file. For example,
>
> I'd reword this like
>
>   ``LLVM_PROFILE_FILE`` can be used to override the directory and filename
>   for the profile file at runtime

Done.

>> +  Without any other arguments, ``-fprofile-use`` behaves identically to
>> +  ``-fprofile-instr-use``. Otherwise, if ``pathname`` is the full path to a
>> +  profile file, it reads from that file. If ``pathname`` is a directory name,
>> +  it reads from ``pathname/pgo-data``.
>
> Apparently we already default to pgo-data, and I actually added that
> code, but I'd rather default to "default.profdata" to mirror
> "default.profraw". It seems the behaviour with the pgo-data name is
> completely undocumented and untested, so it should be fine to switch.

Oh, good. Because I was not liking pgo-data all that much.

>> +  if ((Args.hasArg(options::OPT_fprofile_instr_generate) ||
>> +       Args.hasArg(options::OPT_fprofile_instr_generate_EQ)) &&
>> +      (Args.hasArg(options::OPT_fprofile_generate) ||
>> +       Args.hasArg(options::OPT_fprofile_generate_EQ)))
>> +    D.Diag(diag::err_drv_argument_not_allowed_with)
>> +      << "-fprofile-instr-generate" << "-fprofile-generate";
>> +
>> +  if ((Args.hasArg(options::OPT_fprofile_instr_use) ||
>> +       Args.hasArg(options::OPT_fprofile_instr_use_EQ)) &&
>> +      (Args.hasArg(options::OPT_fprofile_use) ||
>> +       Args.hasArg(options::OPT_fprofile_use_EQ)))
>> +    D.Diag(diag::err_drv_argument_not_allowed_with)
>> +      << "-fprofile-instr-use" << "-fprofile-use";
>> +
>>    if (Arg *A = Args.getLastArg(options::OPT_fprofile_instr_generate_EQ))
>>      A->render(Args, CmdArgs);
>> -  else
>> +  else if (Arg *A = Args.getLastArg(options::OPT_fprofile_generate_EQ))
>> +    A->render(Args, CmdArgs);
>> +  else if (Args.hasArg(options::OPT_fprofile_instr_generate))
>>      Args.AddAllArgs(CmdArgs, options::OPT_fprofile_instr_generate);
>> +  else if (Args.hasArg(options::OPT_fprofile_generate))
>> +    Args.AddAllArgs(CmdArgs, options::OPT_fprofile_generate);
>
> Hm, these (even before your change) behave kind of oddly when multiple
> are specified. If someone specifies multiple forms it would probably
> make more sense to accept the last one, rather than have certain forms
> "win".
>
> We should use the getLastArg form that takes multiple arguments here and
> consolidate these down to a single canonical form for -cc1.

I'm canonicalizing -fprofile-instr-generate down to
-fprofile-instr-generate=default.profraw. But this means that we will
always generate a call to __llvm_profile_override_default_filename().
I don't mind that too much, but before I continue, I wanted to make
sure you're OK with it.

If not, I'll let -cc1 accept both -fprofile-instr-generate and
-fprofile-instr-generate=.


Diego.



More information about the cfe-commits mailing list