Add -fauto-profile option to Clang driver
Diego Novillo
dnovillo at google.com
Tue Oct 22 10:06:23 PDT 2013
On Tue, Oct 22, 2013 at 1:02 PM, Hans Wennborg <hans at chromium.org> wrote:
>> @@ -3034,6 +3034,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
>>
>> // Forward -f options with positive and negative forms; we translate
>> // these by hand.
>> + if (Arg *A = Args.getLastArg(options::OPT_fauto_profile_EQ)) {
>> + StringRef fname = A->getValue();
>> + if (!llvm::sys::fs::exists(fname))
>> + D.Diag(diag::err_drv_no_such_file) << fname;
>> + A->render(Args, CmdArgs);
>> + }
>
> I don't think we should forward the flag to CC1 if the file doesn't
> exist. And maybe we could use DiagnoseInputExistance() in Driver.cpp
> to perform the check - that's the function used to check for regular
> input files.
The driver will exit if the file does not exist. When I try it on my
test programs:
$ ./clang++ -O2 -fauto-profile=nofile.prof branch.cc -o branch
clang: error: no such file or directory: 'nofile.prof'
$ echo $?
1
>> +++ b/test/Driver/clang_f_opts.c
>> @@ -44,6 +44,9 @@
>> // CHECK-UNROLL-LOOPS: "-funroll-loops"
>> // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
>>
>> +// RUN: %clang -### -S -fauto-profile=file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
>> +// CHECK-AUTO-PROFILE: "-fauto-profile=file.prof"
>
> Won't this trigger an error since file.prof doesn't exist? You could
> put an empty file.prof in test/Driver/Inputs.
It doesn't because of -###. If I change the logic to not append the
backend flag if the file does not exist, then I will get an error here
(because we won't match the -f flag). I'll do that since it seems to
be the least surprising approach (though the driver always exiting
with 0 in response to -### was pretty surprising to me).
Thanks. Diego.
More information about the cfe-commits
mailing list