[llvm] r371589 - [Attributor][Fix] Manifest nocapture only in CSArgument or Argument
Hideto Ueno via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 23:52:11 PDT 2019
Author: uenoku
Date: Tue Sep 10 23:52:11 2019
New Revision: 371589
URL: http://llvm.org/viewvc/llvm-project?rev=371589&view=rev
Log:
[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<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.
This is tested in D67286.
Reviewers: jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67342
Modified:
llvm/trunk/lib/Transforms/IPO/Attributor.cpp
Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=371589&r1=371588&r2=371589&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Tue Sep 10 23:52:11 2019
@@ -2594,10 +2594,12 @@ struct AANoCaptureImpl : public AANoCapt
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
More information about the llvm-commits
mailing list