mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 00:56:04 +00:00

This PR removes the old `nocapture` attribute, replacing it with the new `captures` attribute introduced in #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.
40 lines
2.4 KiB
Plaintext
40 lines
2.4 KiB
Plaintext
// Test fir.box_offset code generation.
|
|
// RUN: tco %s | FileCheck %s
|
|
// RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
|
|
|
|
func.func @scalar_addr(%scalar : !fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm_ptr<!fir.ref<!fir.type<t>>> {
|
|
%addr = fir.box_offset %scalar base_addr : (!fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm_ptr<!fir.ref<!fir.type<t>>>
|
|
return %addr : !fir.llvm_ptr<!fir.ref<!fir.type<t>>>
|
|
}
|
|
// CHECK-LABEL: define ptr @scalar_addr(
|
|
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
|
|
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 0
|
|
// CHECK: ret ptr %[[VAL_0]]
|
|
|
|
func.func @scalar_tdesc(%scalar : !fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>> {
|
|
%tdesc = fir.box_offset %scalar derived_type : (!fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
|
|
return %tdesc : !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
|
|
}
|
|
// CHECK-LABEL: define ptr @scalar_tdesc(
|
|
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
|
|
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 7
|
|
// CHECK: ret ptr %[[VAL_0]]
|
|
|
|
func.func @array_addr(%array : !fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.type<t>>>>>) -> !fir.llvm_ptr<!fir.ptr<!fir.array<?x!fir.type<t>>>> {
|
|
%addr = fir.box_offset %array base_addr : (!fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.type<t>>>>>) -> !fir.llvm_ptr<!fir.ptr<!fir.array<?x!fir.type<t>>>>
|
|
return %addr : !fir.llvm_ptr<!fir.ptr<!fir.array<?x!fir.type<t>>>>
|
|
}
|
|
// CHECK-LABEL: define ptr @array_addr(
|
|
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
|
|
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]], ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 0
|
|
// CHECK: ret ptr %[[VAL_0]]
|
|
|
|
func.func @array_tdesc(%array : !fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.type<t>>>>>) -> !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>> {
|
|
%tdesc = fir.box_offset %array derived_type : (!fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.type<t>>>>>) -> !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
|
|
return %tdesc : !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
|
|
}
|
|
// CHECK-LABEL: define ptr @array_tdesc(
|
|
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
|
|
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]], ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 8
|
|
// CHECK: ret ptr %[[VAL_0]]
|