patch: add a driver flag to turn on function merging optimization

Richard Smith richard at metafoo.co.uk
Thu Oct 23 16:42:56 PDT 2014


On Thu, Oct 23, 2014 at 3:24 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> ----- Original Message -----
> > From: "Nick Lewycky" <nlewycky at google.com>
> > To: "llvm cfe" <cfe-commits at cs.uiuc.edu>
> > Sent: Thursday, October 23, 2014 4:39:59 PM
> > Subject: patch: add a driver flag to turn on function merging
> optimization
> >
> > The attached patch adds -fmerge-functions which is in turn attached
> > to PassManagerBuilder::MergeFunctions. This is provided for testing
> > it out, and we can decide what we want the default to be after we
> > have experience. Note that it does bad things to debug info which
> > doesn't currently have a way to represent which function got called
> > if two functions were merged.
>
> So we seem to be somewhat inconsistent about this, but I thought that the
> general pattern was that we resolve the multiple -ffoo vs. -fno-foo in the
> driver, and just pass one relevant flag to -cc1. For example, the code for
> -freroll-loops, -no-integrated-as, etc. does this:
>
>   Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
>   Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,
>                   options::OPT_fno_unroll_loops);
>
>   Args.AddLastArg(CmdArgs, options::OPT_pthread);
>
> and then the -cc1 code just does this:
>
>   if (Args.hasArg(OPT_pthread))
>     Opts.POSIXThreads = 1;
>
>   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
>
>   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
>
> It is unclear to me what the best practice is here, but perhaps it is
> worth a quick clarification.
>

Yes, that's the usual pattern; we try to keep the frontend dumb and put all
the complex resolution of conflicting / overriding flags into the driver.
That means we try to only have flags that change the frontend away from its
default behavior.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141023/aad016f8/attachment.html>


More information about the cfe-commits mailing list