This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Add plumbing to save stats during LTO on Darwin.
ClosedPublic

Authored by fhahn on Apr 10 2019, 8:23 AM.

Details

Summary

Gold and ld on Linux already support saving stats, but the
infrastructure is missing on Darwin. Unfortunately it seems like the
configuration from lib/LTO/LTO.cpp is not used.

This patch adds a new LTOStatsFile option and adds plumbing in Clang to
use it on Darwin, similar to the way remarks are handled.

Currnetly the handling of LTO flags seems quite spread out, with a bunch
of duplication. But I am not sure if there is an easy way to improve
that?

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Apr 10 2019, 8:23 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 10 2019, 8:23 AM
fhahn retitled this revision from [LTO] Add plumbing to save stats during LTO on MacOS. to [LTO] Add plumbing to save stats during LTO on Darwin..Apr 10 2019, 8:25 AM
fhahn edited the summary of this revision. (Show Details)

LGTM with a minor fix needed below.

Darwin still uses the old LTO API, which is why the lto Config based handling in the new LTO API (LTO.h/LTO.cpp) are not being used on this path.

llvm/lib/LTO/LTOCodeGenerator.cpp
101 ↗(On Diff #194524)

Wrong description for this option

steven_wu accepted this revision.Apr 17 2019, 10:48 AM

LGTM with one additional small comments

This revision is now accepted and ready to land.Apr 17 2019, 10:48 AM

forgot to save the inline comments.

llvm/lib/LTO/LTOCodeGenerator.cpp
601 ↗(On Diff #194524)

You can simplify the logic a bit here.

if (StatsFile)
...
else if (llvm::AreStatisticsEnabled())
...
fhahn marked 2 inline comments as done.Apr 19 2019, 4:45 AM

LGTM with a minor fix needed below.

Darwin still uses the old LTO API, which is why the lto Config based handling in the new LTO API (LTO.h/LTO.cpp) are not being used on this path.

Yep, that is unfortunate. I'll create a PR to move it to the new API.

llvm/lib/LTO/LTOCodeGenerator.cpp
101 ↗(On Diff #194524)

Thanks, I'll fix it before I commit the change.

601 ↗(On Diff #194524)

Thanks, I'll fix it before I commit the change.

This revision was automatically updated to reflect the committed changes.