This is an archive of the discontinued LLVM Phabricator instance.

[Attributor][Fix] Manifest nocapture only in CSArgument or Argument
ClosedPublic

Authored by uenoku on Sep 9 2019, 2:17 AM.

Details

Summary

We can query to Attributor whether the value is captured in the scope or not on the following way:

const auto & NoCapAA = A.getAAFor<AANoCapture>(*this, IRPosition::value(V));

And if V is CallSiteReturned then getDeducedAttribute will add nocatpure to the callsite returned value. It is not valid.
This patch checks the position is an argument or call site argument.

Diff Detail

Repository
rL LLVM

Event Timeline

uenoku created this revision.Sep 9 2019, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2019, 2:17 AM

Test missing.

uenoku added a comment.EditedSep 10 2019, 1:19 AM

Test missing.

Yes, test is missing but without this patch, D67286 doesn't work well. If we query whether a callsite retured value is captured in the scope and the value has nocapture, this kind of error will be raised.

Attributes 'byval', 'inalloca', 'nest', 'sret', 'nocapture', 'returned', 'swiftself', and 'swifterror' do not apply to return values!
  %B = tail call noalias nocapture i8* @malloc(i64 4)
in function test12_1
LLVM ERROR: Broken function found, compilation aborted!

I think this fix is trivial then a test is not necessary.

jdoerfert accepted this revision.Sep 10 2019, 9:24 PM

Mention that this is tested in D67286 in the commit message.

This revision is now accepted and ready to land.Sep 10 2019, 9:24 PM
This revision was automatically updated to reflect the committed changes.