This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Support for -save-stats in AddGoldPlugin.
ClosedPublic

Authored by fhahn on Apr 18 2018, 8:02 AM.

Details

Summary

This patch updates AddGoldPlugin to pass stats-file to the Gold plugin,
if -save-stats is passed. It also moves the save-stats option handling
to a helper function tools::getStatsFileName.

Diff Detail

Repository
rC Clang

Event Timeline

fhahn created this revision.Apr 18 2018, 8:02 AM
tejohnson accepted this revision.Apr 19 2018, 8:07 AM

LGTM with comment nit

lib/Driver/ToolChains/CommonArgs.h
109

doxygen comment (looks like there aren't many to start with in this file, but good to add)

This revision is now accepted and ready to land.Apr 19 2018, 8:07 AM
compnerd accepted this revision.Apr 19 2018, 5:44 PM

Some cleanup suggestions included, but I like the change overall.

lib/Driver/ToolChains/CommonArgs.cpp
1283

Early return would be nicer.

const Arg *A = Args.getLastArg(options::OPT_save_stats_EQ);
if (!A)
  return {};
1297

Early return after the check would allow you to avoid the boolean and reduce indentation below too.

if (SaveStats != "cwd" && SaveStats != "obj") {
  D.Diag(drag::err_drv_invalid_value) << A->getAsString(Args) << SaveStats;
  return {};
}
lib/Driver/ToolChains/CommonArgs.h
63–64

While you're here, perhaps you can improve this a slight bit more?

D is unnecessary, ToolChain.getDriver() allows you to get the value anyways. I think it would be nicer to move the Input and Output parameters to before the IsThinLTO.

fhahn updated this revision to Diff 143292.Apr 20 2018, 4:59 AM
fhahn marked 2 inline comments as done.

Thank you very much for the review and the excellent suggestions. I simplified getStatsFileName, added a doxygen comment and changed the arguments of AddGoldPlugin as suggested

fhahn marked 2 inline comments as done.Apr 20 2018, 5:44 AM
This revision was automatically updated to reflect the committed changes.