This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO][CachePruning] explicitly disable pruning
ClosedPublic

Authored by bd1976llvm on Dec 21 2017, 8:52 AM.

Details

Summary

In https://reviews.llvm.org/rL321077 and https://reviews.llvm.org/D41231 I fixed a regression in the c-api which prevented the pruning from being *effectively* disabled.

However this approach, helpfully recommended by @labath, is cleaner.
It is also nice to remove the weasel words about effectively disabling from the api comments.

Diff Detail

Repository
rL LLVM

Event Timeline

bd1976llvm created this revision.Dec 21 2017, 8:52 AM

This looks much cleaner indeed. lgtm, but please wait for signoff from the LTO folks as well.

include/llvm/Support/CachePruning.h
31 ↗(On Diff #127897)

Maybe document the meaning of llvm::None ?

Addressed review comments

bd1976llvm marked an inline comment as done.Dec 22 2017, 3:42 AM

Thanks this looks much nicer. Question below about the handling of the Optional though.

As an aside, it would be great to have similar handling in parseCachePruningPolicy(), which is used by gold-plugin and lld, and which gives an error when -1 is passed as the interval. But that doesn't need to be in this patch, just noting it here.

lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

Wouldn't this need to be *Policy.Interval, like in the below <= check?

bd1976llvm marked an inline comment as done.Dec 22 2017, 8:15 AM

Thanks this looks much nicer. Question below about the handling of the Optional though.

As an aside, it would be great to have similar handling in parseCachePruningPolicy(), which is used by gold-plugin and lld, and which gives an error when -1 is passed as the interval. But that doesn't need to be in this patch, just noting it here.

If possible I would rather do that in another change.

lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

The != operator is overloaded so it does the right thing.

Thanks this looks much nicer. Question below about the handling of the Optional though.

As an aside, it would be great to have similar handling in parseCachePruningPolicy(), which is used by gold-plugin and lld, and which gives an error when -1 is passed as the interval. But that doesn't need to be in this patch, just noting it here.

If possible I would rather do that in another change.

Agree

lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

Ah ok, see that. It looks like <= has the same overloads - can the * be removed there?

bd1976llvm marked an inline comment as done.Dec 22 2017, 9:58 AM
bd1976llvm added inline comments.
lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

Nope. On some platforms, e.g. windows, the type of TimeStampModTime is nanoseconds. Therefore, none of the Optional <= operator overloads will match.

tejohnson accepted this revision.Dec 22 2017, 10:18 AM

LGTM assuming the answer to my question below is "yes". =)

lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

Oh I see. I suppose there are <= overloads to make the comparison between the Interval in std::chrono::seconds and a TimeStampModTime in nanoseconds work as desired?

This revision is now accepted and ready to land.Dec 22 2017, 10:18 AM
bd1976llvm marked 4 inline comments as done.Dec 22 2017, 10:25 AM
bd1976llvm added inline comments.
lib/Support/CachePruning.cpp
170 ↗(On Diff #128006)

Indeed. What will happen is that a nanoseconds type will be constructed from the Policy.Interval which is of type seconds (this is where there is potential for overflow) and then the comparison will be between the two seconds types.

This revision was automatically updated to reflect the committed changes.
bd1976llvm marked an inline comment as done.