[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-29 Thread Nikita Popov via cfe-commits

https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Nikita Popov via cfe-commits

nikic wrote:

Thanks for the reviews! I plan to land this after LLVM 20 branches next week, 
to avoid unnecessary last-minute disruption for the release.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits


@@ -526,6 +526,11 @@ static AttributeSet 
getIntrinsicArgAttributeSet(LLVMContext &C, unsigned ID) {
 )",
 ID);
   for (const CodeGenIntrinsic::ArgAttribute &Attr : Attrs) {
+if (Attr.Kind == CodeGenIntrinsic::NoCapture) {

fhahn wrote:

Sounds good, as long as it will be renamed eventually.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits

https://github.com/fhahn approved this pull request.

LGTM, thanks

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits

https://github.com/fhahn edited https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Nikita Popov via cfe-commits


@@ -526,6 +526,11 @@ static AttributeSet 
getIntrinsicArgAttributeSet(LLVMContext &C, unsigned ID) {
 )",
 ID);
   for (const CodeGenIntrinsic::ArgAttribute &Attr : Attrs) {
+if (Attr.Kind == CodeGenIntrinsic::NoCapture) {

nikic wrote:

I'd prefer doing that in a followup, to avoid a mass-change of Intrinsic.td 
files in this PR. I think we'll also want to expose at least CapturesRetOnly, 
as some intrinsics want those semantics. Not sure if any intrinsics need 
something other than CapturesNone/CapturesRetOnly -- exposing the attribute in 
full generality in TableGen would probably be rather annoying.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits


@@ -526,6 +526,11 @@ static AttributeSet 
getIntrinsicArgAttributeSet(LLVMContext &C, unsigned ID) {
 )",
 ID);
   for (const CodeGenIntrinsic::ArgAttribute &Attr : Attrs) {
+if (Attr.Kind == CodeGenIntrinsic::NoCapture) {

fhahn wrote:

Should NoCapture->CapturesNone (or something like that) here as well for 
consistency? Although might further increase the diff :) 

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Nikita Popov via cfe-commits

nikic wrote:

> Just double checking, do we have a test for the auto-upgrade?

All the compatibility-*.ll tests test auto-upgrade.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Nikita Popov via cfe-commits


@@ -1015,7 +1015,7 @@ struct OperandBundleUse {
   /// has the attribute A.
   bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const {
 if (isDeoptOperandBundle())
-  if (A == Attribute::ReadOnly || A == Attribute::NoCapture)

nikic wrote:

Yes.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits


@@ -1015,7 +1015,7 @@ struct OperandBundleUse {
   /// has the attribute A.
   bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const {
 if (isDeoptOperandBundle())
-  if (A == Attribute::ReadOnly || A == Attribute::NoCapture)

fhahn wrote:

This case is now handled by getCaptureInfo, correct?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits

https://github.com/fhahn commented:

Just double checking, do we have a test for the auto-upgrade?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-21 Thread Florian Hahn via cfe-commits

https://github.com/fhahn edited https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-20 Thread via cfe-commits

goldsteinn wrote:

This LGTM, although think needs other approvals.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-20 Thread via cfe-commits

https://github.com/goldsteinn edited 
https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-20 Thread via cfe-commits


@@ -1986,6 +1986,12 @@ static void decodeLLVMAttributesForBitcode(AttrBuilder 
&B,
   B.addMemoryAttr(ME);
   }
 
+  // Upgrade nocapture to captures(none).
+  if (Attrs & (1ULL << 21)) {
+Attrs &= ~(1ULL << 21);

goldsteinn wrote:

Maybe also mention that 1 << 21 is `NoCapture` here.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-20 Thread via cfe-commits


@@ -1663,16 +1663,14 @@ class CallBase : public Instruction {
 return bundleOperandHasAttr(i, Kind);
   }
 
+  /// Return which pointer components this operand may capture.
+  CaptureInfo getCaptureInfo(unsigned OpNo) const;
+
   /// Determine whether this data operand is not captured.
   // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
   // better indicate that this may return a conservative answer.
   bool doesNotCapture(unsigned OpNo) const {
-// If the argument is passed byval, the callee does not have access to the
-// original pointer and thus cannot capture it.
-if (OpNo < arg_size() && isByValArgument(OpNo))
-  return true;

goldsteinn wrote:

Why drop this code?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-20 Thread Nikita Popov via cfe-commits


@@ -8,14 +8,14 @@ typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias writable 
writeonly sret
 // N64: define{{.*}} inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
-// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret
+// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret

nikic wrote:

I landed 
https://github.com/llvm/llvm-project/commit/a4d9a8de0820f3ccc2eb35870cac199e8dacd9e6
 to avoid the confusing diff in this PR. (As well as a couple of other changes 
to reduce the test diff in this PR a bit.)

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread via cfe-commits

https://github.com/goldsteinn edited 
https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread via cfe-commits

https://github.com/goldsteinn edited 
https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread via cfe-commits


@@ -5742,27 +5742,36 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const 
IRPosition &IRP,
 return true;
   }
 
-  if (A.hasAttr(IRP, {Attribute::NoCapture},
-/* IgnoreSubsumingPositions */ true, Attribute::NoCapture))
-return true;
+  SmallVector Attrs;
+  A.getAttrs(IRP, {Attribute::Captures}, Attrs,
+ /* IgnoreSubsumingPositions */ true);
+  for (const Attribute &Attr : Attrs)
+if (capturesNothing(Attr.getCaptureInfo()))
+  return true;
 
   if (IRP.getPositionKind() == IRP_CALL_SITE_ARGUMENT)
-if (Argument *Arg = IRP.getAssociatedArgument())
-  if (A.hasAttr(IRPosition::argument(*Arg),
-{Attribute::NoCapture, Attribute::ByVal},
-/* IgnoreSubsumingPositions */ true)) {
-A.manifestAttrs(IRP,
-Attribute::get(V.getContext(), Attribute::NoCapture));
+if (Argument *Arg = IRP.getAssociatedArgument()) {
+  SmallVector Attrs;

goldsteinn wrote:

2? Or default?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread Nikita Popov via cfe-commits


@@ -8,14 +8,14 @@ typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias writable 
writeonly sret
 // N64: define{{.*}} inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
-// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret
+// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret

nikic wrote:

captures is an integer attribute, so it sorts after type attributes like sret. 
It's still printed, just not being matched here.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread via cfe-commits


@@ -8,14 +8,14 @@ typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias writable 
writeonly sret
 // N64: define{{.*}} inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
-// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret
+// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret

goldsteinn wrote:

Why is it no longer printing?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread Nikita Popov via cfe-commits


@@ -8,14 +8,14 @@ typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias writable 
writeonly sret
 // N64: define{{.*}} inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
-// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret
+// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret

nikic wrote:

The attribute is still there, but the only thing really relevant to this test 
is the sret.

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [IR] Convert from nocapture to captures(none) (PR #123181)

2025-01-18 Thread via cfe-commits


@@ -8,14 +8,14 @@ typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4sf(ptr dead_on_unwind noalias writable 
writeonly sret
 // N64: define{{.*}} inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
-// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias 
nocapture writable writeonly sret
+// O32-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret
+// N64-LABEL: define{{.*}} void @test_v4df(ptr dead_on_unwind noalias writable 
writeonly sret

goldsteinn wrote:

Expected `captures(none)` here?

https://github.com/llvm/llvm-project/pull/123181
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits