This is an archive of the discontinued LLVM Phabricator instance.

[Partial Inliner] Compute intrinsic cost through TTI
ClosedPublic

Authored by tdangeti on Sep 4 2020, 2:21 AM.

Details

Summary

https://bugs.llvm.org/show_bug.cgi?id=45932

assert(OutlinedFunctionCost >= Cloner.OutlinedRegionCost && "Outlined function cost should be no less than the outlined region") getting triggered in computeBBInlineCost.

Intrinsics like "assume" are considered regular function calls while computing costs.
This patch enables computeBBInlineCost to queries TTI for intrinsic call cost.

Diff Detail

Event Timeline

tdangeti created this revision.Sep 4 2020, 2:21 AM
tdangeti requested review of this revision.Sep 4 2020, 2:21 AM
tdangeti added a reviewer: jonpa.
tdangeti updated this revision to Diff 289928.Sep 4 2020, 5:52 AM

Formated code.

Please upload all patches with full context;
tests missing

fhahn added a subscriber: fhahn.Sep 4 2020, 6:11 AM
tdangeti updated this revision to Diff 289942.Sep 4 2020, 6:58 AM

Added test case.

tdangeti updated this revision to Diff 289943.Sep 4 2020, 7:01 AM
fhahn added a comment.Sep 6 2020, 7:25 AM

It would be great if you could upload the patch with more context in the diff (see https://llvm.org/docs/Phabricator.html#phabricator-request-review-web, e.g. use git show HEAD -U999999 > mypatch.patch if you use git to generate the diff).

llvm/test/Transforms/PartialInlining/intrinsic-call-cost.ll
2

Thanks for adding the test case. Please also use FileCheck to make sure the resulting IR is sensible.

12

Can we just return here instead of unreachable?

15

nit: dso_local / local_unnamed_addr may be not needed?

tdangeti updated this revision to Diff 290960.Sep 10 2020, 6:45 AM

Added CHECKs to the test case.

tdangeti marked 3 inline comments as done.Sep 10 2020, 6:46 AM
fhahn added inline comments.Sep 10 2020, 12:23 PM
llvm/lib/Transforms/IPO/PartialInlining.cpp
875

you can use if (auto *II = dyn_cast<IntrinsicInst>(&I))

881

Is it possible to just use II->args()?

llvm/test/Transforms/PartialInlining/intrinsic-call-cost.ll
2

Can you also add a reference to the bug in the comment here?

And the file mode seems a bit odd. The file does not need to be executable.

tdangeti updated this revision to Diff 291128.Sep 10 2020, 9:51 PM

Addressed comments.

tdangeti marked 3 inline comments as done.Sep 10 2020, 9:52 PM
tdangeti updated this revision to Diff 291454.Sep 13 2020, 5:34 AM
tdangeti edited reviewers, added: davidxl, fhahn; removed: venur, sekharbvrs.Sep 15 2020, 1:22 AM
fhahn accepted this revision.Sep 15 2020, 1:32 AM

LGTM, thanks for fixing this issue!

llvm/test/Transforms/PartialInlining/intrinsic-call-cost.ll
4

Not sure if it is a good idea to include the assertion here, as it may change in the code. It might be better to just explain what the test does, e.g. something like Check that valid costs are computed for intrinsic calls..

7

Could you move this to the top?

This revision is now accepted and ready to land.Sep 15 2020, 1:32 AM
tdangeti updated this revision to Diff 291871.Sep 15 2020, 5:20 AM
tdangeti marked an inline comment as done.

Removed the "assert" comment from test case.

tdangeti updated this revision to Diff 292112.Sep 15 2020, 10:45 PM
tdangeti marked an inline comment as done.

LGTM, thanks for fixing this issue!

Thanks for reviewing.
I don't have commit rights. Could you please commit on my behalf?

fhahn added a comment.Sep 16 2020, 2:58 AM

LGTM, thanks for fixing this issue!

Thanks for reviewing.
I don't have commit rights. Could you please commit on my behalf?

Sure, I can do that. I will use the name from your phab profile and the mail used.

Sure, I can do that. I will use the name from your phab profile and the mail used.

Thanks again for taking the time to review and commit.

This revision was automatically updated to reflect the committed changes.