Page MenuHomePhabricator

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

Authored by uenoku on Mon, Sep 9, 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.Mon, Sep 9, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Sep 9, 2:17 AM

Test missing.

uenoku added a comment.EditedTue, Sep 10, 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.Tue, Sep 10, 9:24 PM

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

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