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

Hal Finkel hfinkel at
Thu Oct 23 15:24:56 PDT 2014

----- Original Message -----
> From: "Nick Lewycky" <nlewycky at>
> To: "llvm cfe" <cfe-commits at>
> 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,

  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.

Thanks again,

> Please review!
> Nick
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at

Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory

More information about the cfe-commits mailing list