This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Implement "norecurse" function attribute deduction
ClosedPublic

Authored by uenoku on Sep 19 2019, 1:52 AM.

Details

Summary

This patch introduces norecurse function attribute deduction.

norecurse will be deduced if the following conditions hold:

  • The size of SCC in which the function belongs equals to 1.
  • The function doesn't have self-recursion.
  • We have norecurse for all call site.

To avoid a large change, SCC is calculated using scc_iterator in InfoCache initialization for now.

Diff Detail

Event Timeline

uenoku created this revision.Sep 19 2019, 1:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2019, 1:52 AM

Thx, I have a few minor comments, mostly wrt. to the test.

llvm/include/llvm/Transforms/IPO/Attributor.h
547

nit: Make it MAM.

568

nit: can you add a newline here :)

llvm/test/Transforms/FunctionAttrs/norecurse.ll
129

do we have a function pointer test?
do we have a test with recursion through a dead call site?

llvm/test/Transforms/FunctionAttrs/willreturn.ll
526

Willreturn uses norecurse, could we have a test to show how this improved willreturn?

uenoku updated this revision to Diff 221023.Sep 20 2019, 7:04 AM

Address comment

uenoku marked 5 inline comments as done.Sep 20 2019, 7:08 AM
uenoku added inline comments.
llvm/test/Transforms/FunctionAttrs/norecurse.ll
129

I added both. See below.

llvm/test/Transforms/FunctionAttrs/willreturn.ll
526

I change Test8 a bit and willreturn and norecurse will be propagated in the test.

This revision is now accepted and ready to land.Sep 20 2019, 7:08 PM
This revision was automatically updated to reflect the committed changes.
uenoku marked an inline comment as done.