This is an archive of the discontinued LLVM Phabricator instance.

Let FuncAttrs infer the 'returned' argument attribute
ClosedPublic

Authored by hfinkel on Jul 10 2016, 11:40 AM.

Details

Summary

A function can have one argument with the 'returned' attribute, indicating that the associated argument is always the return value of the function. Add FuncAttrs inference logic.

I intend to make the optimizer smarter about looking through functions with a returned parameter (in support of the llvm.noalias intrinsic). We might as well let generic functions with this property benefit as well.

Diff Detail

Repository
rL LLVM

Event Timeline

hfinkel updated this revision to Diff 63431.Jul 10 2016, 11:40 AM
hfinkel retitled this revision from to Let FuncAttrs infer the 'returned' argument attribute.
hfinkel updated this object.
hfinkel added a subscriber: llvm-commits.
jmolloy accepted this revision.Jul 10 2016, 11:44 AM
jmolloy edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Jul 10 2016, 11:44 AM
majnemer requested changes to this revision.Jul 10 2016, 1:13 PM
majnemer edited edge metadata.

I'd update the langref, it currently says:

This is an optimization hint to the code generator when generating the caller

lib/Transforms/IPO/FunctionAttrs.cpp
494–495 ↗(On Diff #63431)

Is this comment correct?

508 ↗(On Diff #63431)

auto *Ret

This revision now requires changes to proceed.Jul 10 2016, 1:13 PM

I'd update the langref, it currently says:

This is an optimization hint to the code generator when generating the caller

Yes; that part is actually already out-of-date. I'll post a separate patch for that.

I'd update the langref, it currently says:

This is an optimization hint to the code generator when generating the caller

Yes; that part is actually already out-of-date. I'll post a separate patch for that.

Posted D22203 for the LangRef update.

hfinkel updated this revision to Diff 63434.Jul 10 2016, 2:06 PM
hfinkel edited edge metadata.

Updated per review comments.

majnemer accepted this revision.Jul 10 2016, 2:36 PM
majnemer edited edge metadata.

LGTM

lib/Transforms/IPO/FunctionAttrs.cpp
506–515 ↗(On Diff #63434)

Hmm, should we skip the function when RetArgs.size() > 1?

This revision is now accepted and ready to land.Jul 10 2016, 2:36 PM
hfinkel added inline comments.Jul 10 2016, 3:03 PM
lib/Transforms/IPO/FunctionAttrs.cpp
506–515 ↗(On Diff #63434)

Yes, because we can only mark one attribute as returned (i.e. it is otherwise uncertain which argument will be returned, so we can mark neither).

This revision was automatically updated to reflect the committed changes.