[PATCH] D67342: [Attributor][Fix] Manifest nocapture only in CSArgument or Argument

Hideto Ueno via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 02:18:06 PDT 2019


uenoku created this revision.
uenoku added reviewers: jdoerfert, sstefan1.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

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.


https://reviews.llvm.org/D67342

Files:
  llvm/lib/Transforms/IPO/Attributor.cpp


Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2594,10 +2594,12 @@
     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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67342.219298.patch
Type: text/x-patch
Size: 832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190909/b573147e/attachment.bin>


More information about the llvm-commits mailing list