From: Hideto Ueno Date: Wed, 11 Sep 2019 06:52:11 +0000 (+0000) Subject: [Attributor][Fix] Manifest nocapture only in CSArgument or Argument X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58dc7cdf01f4bdbad3ad08a1443c362b8b24ed58;p=llvm [Attributor][Fix] Manifest nocapture only in CSArgument or Argument 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(*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. This is tested in D67286. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67342 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371589 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/Attributor.cpp b/lib/Transforms/IPO/Attributor.cpp index 0a15b3e09a7..064791897a5 100644 --- a/lib/Transforms/IPO/Attributor.cpp +++ b/lib/Transforms/IPO/Attributor.cpp @@ -2594,10 +2594,12 @@ struct AANoCaptureImpl : public AANoCapture { if (!isAssumedNoCaptureMaybeReturned()) return; - if (isAssumedNoCapture()) - Attrs.emplace_back(Attribute::get(Ctx, Attribute::NoCapture)); - else if (ManifestInternal) - Attrs.emplace_back(Attribute::get(Ctx, "no-capture-maybe-returned")); + if (getArgNo() >= 0) { + if (isAssumedNoCapture()) + Attrs.emplace_back(Attribute::get(Ctx, Attribute::NoCapture)); + else if (ManifestInternal) + Attrs.emplace_back(Attribute::get(Ctx, "no-capture-maybe-returned")); + } } /// Set the NOT_CAPTURED_IN_MEM and NOT_CAPTURED_IN_RET bits in \p Known