Skip to content

Commit 90e2e07

Browse files
nikicronlieb
authored andcommitted
[IR] Convert from nocapture to captures(none) (llvm#123181)
This PR removes the old `nocapture` attribute, replacing it with the new `captures` attribute introduced in llvm#116990. This change is intended to be essentially NFC, replacing existing uses of `nocapture` with `captures(none)` without adding any new analysis capabilities. Making use of non-`none` values is left for a followup. Some notes: * `nocapture` will be upgraded to `captures(none)` by the bitcode reader. * `nocapture` will also be upgraded by the textual IR reader. This is to make it easier to use old IR files and somewhat reduce the test churn in this PR. * Helper APIs like `doesNotCapture()` will check for `captures(none)`. * MLIR import will convert `captures(none)` into an `llvm.nocapture` attribute. The representation in the LLVM IR dialect should be updated separately.
1 parent 07ba9a2 commit 90e2e07

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -5752,8 +5752,7 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
57525752
if (IRP.getPositionKind() == IRP_CALL_SITE_ARGUMENT)
57535753
if (Argument *Arg = IRP.getAssociatedArgument()) {
57545754
SmallVector<Attribute, 1> Attrs;
5755-
A.getAttrs(IRPosition::argument(*Arg),
5756-
{Attribute::Captures, Attribute::ByVal}, Attrs,
5755+
A.getAttrs(IRP, {Attribute::Captures, Attribute::ByVal}, Attrs,
57575756
/* IgnoreSubsumingPositions */ true);
57585757
bool ArgNoCapture = any_of(Attrs, [](Attribute Attr) {
57595758
return Attr.getKindAsEnum() == Attribute::ByVal ||

llvm/test/Transforms/Attributor/liveness.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,7 @@ define internal void @call_via_pointer_with_dead_args_internal_a(ptr %a, ptr %b,
23642364
;
23652365
; CGSCC-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
23662366
; CGSCC-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
2367-
; CGSCC-NEXT: call void @called_via_pointer(ptr [[A]], ptr nofree noundef nonnull align 128 captures(none) dereferenceable(4) [[B]], ptr nofree captures(none) [[A]], i64 noundef -1, ptr nofree noundef null)
2367+
; CGSCC-NEXT: call void @called_via_pointer(ptr [[A]], ptr nofree noundef nonnull align 128 dereferenceable(4) [[B]], ptr nofree [[A]], i64 noundef -1, ptr nofree noundef null)
23682368
; CGSCC-NEXT: ret void
23692369
;
23702370
call void %fp(ptr %a, ptr %b, ptr %a, i64 -1, ptr null)

llvm/test/Transforms/Attributor/nonnull.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ define internal void @optnone(ptr dereferenceable(4) %a) optnone noinline {
10581058
; CHECK: Function Attrs: noinline optnone
10591059
; CHECK-LABEL: define {{[^@]+}}@optnone
10601060
; CHECK-SAME: (ptr noundef nonnull dereferenceable(4) [[A:%.*]]) #[[ATTR12:[0-9]+]] {
1061-
; CHECK-NEXT: call void @use_i32_ptr(ptr nofree noundef nonnull captures(none) [[A]])
1061+
; CHECK-NEXT: call void @use_i32_ptr(ptr nofree noundef nonnull [[A]])
10621062
; CHECK-NEXT: ret void
10631063
;
10641064
call void @use_i32_ptr(ptr %a)

0 commit comments

Comments
 (0)