This is an archive of the discontinued LLVM Phabricator instance.

Emit only A Single Opt Remark When Inlining
ClosedPublic

Authored by lenary on Jul 29 2017, 8:52 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

lenary created this revision.Jul 29 2017, 8:52 PM
lenary added inline comments.Jul 29 2017, 8:54 PM
lib/Transforms/IPO/Inliner.cpp
557 ↗(On Diff #108815)

I'm not sure of the overhead of re-computing the InlineCost, which is used below. Maybe I should also return it (using an output parameter) from shouldInline above?

anemet added inline comments.
lib/Transforms/IPO/Inliner.cpp
557 ↗(On Diff #108815)

Yes, that is what I was thinking of doing.

lenary added inline comments.Jul 30 2017, 11:17 PM
lib/Transforms/IPO/Inliner.cpp
557 ↗(On Diff #108815)

Ok, I will update the patch to do so.

lenary updated this revision to Diff 108869.Jul 31 2017, 12:23 AM

Update shouldInline in Inliner to return the InlineCost, rather
than recomputing the cost.

I had to be a little hack-y around TotalSecondaryCost, but
I couldn't see a better way to do that.

Also I added a getThreshold() method to InlineCost for use in
messages, rather than reversing how getCostDelta() is calculated.

Any progress on the reviews?

anemet added inline comments.Aug 8 2017, 3:50 PM
lib/Transforms/IPO/Inliner.cpp
387–389 ↗(On Diff #108869)

I am fine with this. Alternatively we could change the return type to Optional<InlineCost> and return None here and check (!IC || !*IC) in the caller but that seems like an overkill.

577–581 ↗(On Diff #108869)

No {} around a single statement.

879–882 ↗(On Diff #108869)

Isn't this the path via the new PM? Don't you need to emit the remarks for the successful inlining here as well?

Should probably add a test for this if I am right ;).

lenary added a comment.Aug 8 2017, 3:58 PM

Thanks for that review, I'll get onto doing the changes you've asked for.

lib/Transforms/IPO/Inliner.cpp
387–389 ↗(On Diff #108869)

I think Optional<InlineCost> might be a better solution than a magic value that happens to do what we want. I'll see what changing to that does.

577–581 ↗(On Diff #108869)

Sure. I thought I had run clang-format, but it evidently didn't catch this. I'll do it manually.

879–882 ↗(On Diff #108869)

Ok, I didn't understand why there were two implementations, one for each pass makes more sense.

I need to fix that bug with the path option, which might need to land first, so that tests start failing.

lenary updated this revision to Diff 111758.Aug 18 2017, 3:36 PM

Address review feedback.

Using Optional<InlineCost> seemed to be a good compromise,
so I have used it.

I also am now emitting more optimisation remarks in the new
pass.

anemet added inline comments.Aug 18 2017, 4:32 PM
lib/Transforms/IPO/Inliner.cpp
353 ↗(On Diff #111758)

Don't we have a ctor that converts from T? I.e. can't you just say return IC?

363 ↗(On Diff #111758)

return None?

579–580 ↗(On Diff #111758)

How about: OIC->isAlways()

879–882 ↗(On Diff #108869)

I need to fix that bug with the path option, which might need to land first, so that tests start failing.

SGTM.

lenary updated this revision to Diff 111771.Aug 18 2017, 4:49 PM
lenary marked 3 inline comments as done.

Address Review Comments

anemet accepted this revision.Aug 18 2017, 4:52 PM

LGTM. Are you going to commit this as is or fix the new PM -pass-remarks-output first and update this? I am fine either way.

This revision is now accepted and ready to land.Aug 18 2017, 4:52 PM

LGTM. Are you going to commit this as is or fix the new PM -pass-remarks-output first and update this? I am fine either way.

I think I'm going to pause on this patch for a moment until the other is accepted and committed.

I think I have that fix (as far as code is concerned), but I think that patch should include updating all tests that currently only use the old pass manager to emit remark yaml files to also make them do exactly the same with the new pass manager, and that will take a little longer. Expect the complete patch of both code and tests some time over the weekend, I think.

LGTM. Are you going to commit this as is or fix the new PM -pass-remarks-output first and update this? I am fine either way.

I think I'm going to pause on this patch for a moment until the other is accepted and committed.

I think I have that fix (as far as code is concerned), but I think that patch should include updating all tests that currently only use the old pass manager to emit remark yaml files to also make them do exactly the same with the new pass manager, and that will take a little longer. Expect the complete patch of both code and tests some time over the weekend, I think.

Awesome!

lenary updated this revision to Diff 111865.Aug 19 2017, 11:36 PM

Add Tests that use NewPM

The only issue here is that the NewPM's inline pass does not emit remarks that say "foo will not be inlined into bar because its definition is unavailable", which seems to be to do with how the inline pass finds candidates to inline (the queue it uses never even admits declaration-only functions). I'm not sure this is a major problem per se, but we should perhaps look at re-adding this functionality later.

This revision was automatically updated to reflect the committed changes.
lenary reopened this revision.Aug 20 2017, 12:00 AM

This caused some clang and lld build failures.

I've reverted the commit in https://reviews.llvm.org/rL311274 so we can fix tests and look at re-applying it later.

This revision is now accepted and ready to land.Aug 20 2017, 12:00 AM

Ok, I have patches for the two other repositories which had failing tests.

I have no idea how to make these all land at the same time, but roughly the same time is ok too, I think.

LGTM. Are you going to commit this as is or fix the new PM -pass-remarks-output first and update this? I am fine either way.

Ok, I have patches for the two other repositories which had failing tests.

I have no idea how to make these all land at the same time, but roughly the same time is ok too, I think.

Yep, just be prepared to see bot failures if an intermittent version is picked up by a bot.

LGTM. Are you going to commit this as is or fix the new PM -pass-remarks-output first and update this? I am fine either way.

...

Yep, just be prepared to see bot failures if an intermittent version is picked up by a bot.

The New PM pass remarks output fix landed on Saturday, and I updated these tests to use the NewPM too (see the diffs to test/Trasforms/Inline/optimization*).

Yeah, intermittent but expected failures I can cope with, unexpected ones are less fun.

lenary updated this revision to Diff 112003.Aug 21 2017, 9:45 AM

Update Patch against current trunk

This revision was automatically updated to reflect the committed changes.