I'm trying to add a new option to clang to enable my auto profile pass. I've added this to Options.td and Driver/Tools.cpp, but I'm not getting the option -auto-profile in cc1's invocation. I've checked that the code to push -auto-profile is executed, but if use -v, I don't see -auto-profile in the cc1 invocation. Can anyone point me to some document that explains how to pass clang's options down to opt? Failing that, what option could I look at copying? I've tried doing what the vectorizer flags do, but they are used to build the module pass manager, and my pass is just a function pass. Do I need to modify the pass manager as well? Thanks. Diego. diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index a2be903..da932e2 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -351,6 +351,10 @@ def fno_autolink : Flag <["-"], "fno-autolink">, Group<f_Group>, Flags<[DriverOption, CC1Option]>, HelpText<"Disable generation of linker directives for automatic library linking">; +def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>, + Flags<[DriverOption, CC1Option]>, + HelpText<"Enable automatic profile guided optimizations">; + def fblocks : Flag<["-"], "fblocks">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Enable the 'blocks' language feature">; def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group<f_Group>; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index dd48bc1..729da37 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -3594,6 +3594,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer" << A->getAsString(Args); + if (Args.hasArg(options::OPT_fauto_profile)) { + CmdArgs.push_back("-auto-profile"); + } + // Claim some arguments which clang supports automatically. // -fpch-preprocess is used with gcc to add a special marker in the output to
On Tue, Oct 1, 2013 at 3:31 PM, Diego Novillo <dnovillo at google.com> wrote:> Do I need to modify the pass manager as well?Actually, I think I do need to modify the PM. I need to insert the annotations before the analysis passes execute. Diego.
Rafael EspĂndola
2013-Oct-01 19:42 UTC
[LLVMdev] RFH: passing options from clang down to opt
You are calling the option -auto-profile in some places and -fauto-profile in others. Maybe it is just a typo? On 1 October 2013 15:31, Diego Novillo <dnovillo at google.com> wrote:> I'm trying to add a new option to clang to enable my auto profile > pass. I've added this to Options.td and Driver/Tools.cpp, but I'm not > getting the option -auto-profile in cc1's invocation. I've checked > that the code to push -auto-profile is executed, but if use -v, I > don't see -auto-profile in the cc1 invocation. > > Can anyone point me to some document that explains how to pass clang's > options down to opt? Failing that, what option could I look at > copying? I've tried doing what the vectorizer flags do, but they are > used to build the module pass manager, and my pass is just a function > pass. > > Do I need to modify the pass manager as well? > > Thanks. Diego. > > diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td > index a2be903..da932e2 100644 > --- a/include/clang/Driver/Options.td > +++ b/include/clang/Driver/Options.td > @@ -351,6 +351,10 @@ def fno_autolink : Flag <["-"], "fno-autolink">, > Group<f_Group>, > Flags<[DriverOption, CC1Option]>, > HelpText<"Disable generation of linker directives for automatic > library linking">; > > +def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>, > + Flags<[DriverOption, CC1Option]>, > + HelpText<"Enable automatic profile guided optimizations">; > + > def fblocks : Flag<["-"], "fblocks">, Group<f_Group>, Flags<[CC1Option]>, > HelpText<"Enable the 'blocks' language feature">; > def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group<f_Group>; > diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp > index dd48bc1..729da37 100644 > --- a/lib/Driver/Tools.cpp > +++ b/lib/Driver/Tools.cpp > @@ -3594,6 +3594,11 @@ void Clang::ConstructJob(Compilation &C, const > JobAction &JA, > D.Diag(diag::err_drv_argument_not_allowed_with) > << "-fomit-frame-pointer" << A->getAsString(Args); > > + if (Args.hasArg(options::OPT_fauto_profile)) { > + CmdArgs.push_back("-auto-profile"); > + } > + > // Claim some arguments which clang supports automatically. > > // -fpch-preprocess is used with gcc to add a special marker in the output to > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Tue, Oct 1, 2013 at 3:42 PM, Rafael EspĂndola <rafael.espindola at gmail.com> wrote:> You are calling the option -auto-profile in some places and > -fauto-profile in others. Maybe it is just a typo?In opt, the option is named '-auto-profile' when I instantiate the pass: INITIALIZE_PASS(AutoProfile, "auto-profile", "Auto Profile loader", false, false) Do I need to name it fauto-profile as well? I'm also not sure how to schedule the pass at a specific spot in the pass manager. I've looked around for documentation on adding flags, but all I found was http://llvm.org/docs/WritingAnLLVMPass.html#pass-registration which does not seem to discuss this. Diego.
Seemingly Similar Threads
- [LLVMdev] RFH: passing options from clang down to opt
- [LLVMdev] RFH: passing options from clang down to opt
- a question about glht function
- [LLVMdev] RFH: passing options from clang down to opt
- [LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)