Skip to content

Commit 07915a0

Browse files
vzakharisivan-shani
authored andcommitted
[flang] Added noalias attribute to function arguments. (llvm#140803)
This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ``` ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. ``` I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram.
1 parent 22b6f21 commit 07915a0

30 files changed

+265
-112
lines changed

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
431431
"Set the unsafe-fp-math attribute on functions in the module.">,
432432
Option<"tuneCPU", "tune-cpu", "std::string", /*default=*/"",
433433
"Set the tune-cpu attribute on functions in the module.">,
434+
Option<"setNoCapture", "set-nocapture", "bool", /*default=*/"false",
435+
"Set LLVM nocapture attribute on function arguments, "
436+
"if possible">,
437+
Option<"setNoAlias", "set-noalias", "bool", /*default=*/"false",
438+
"Set LLVM noalias attribute on function arguments, "
439+
"if possible">,
434440
];
435441
}
436442

flang/lib/Optimizer/Passes/Pipelines.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,15 @@ void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
350350
else
351351
framePointerKind = mlir::LLVM::framePointerKind::FramePointerKind::None;
352352

353+
bool setNoCapture = false, setNoAlias = false;
354+
if (config.OptLevel.isOptimizingForSpeed())
355+
setNoCapture = setNoAlias = true;
356+
353357
pm.addPass(fir::createFunctionAttr(
354358
{framePointerKind, config.InstrumentFunctionEntry,
355359
config.InstrumentFunctionExit, config.NoInfsFPMath, config.NoNaNsFPMath,
356360
config.ApproxFuncFPMath, config.NoSignedZerosFPMath, config.UnsafeFPMath,
357-
""}));
361+
/*tuneCPU=*/"", setNoCapture, setNoAlias}));
358362

359363
if (config.EnableOpenMP) {
360364
pm.addNestedPass<mlir::func::FuncOp>(

flang/lib/Optimizer/Transforms/FunctionAttr.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,8 @@ namespace {
2727

2828
class FunctionAttrPass : public fir::impl::FunctionAttrBase<FunctionAttrPass> {
2929
public:
30-
FunctionAttrPass(const fir::FunctionAttrOptions &options) {
31-
instrumentFunctionEntry = options.instrumentFunctionEntry;
32-
instrumentFunctionExit = options.instrumentFunctionExit;
33-
framePointerKind = options.framePointerKind;
34-
noInfsFPMath = options.noInfsFPMath;
35-
noNaNsFPMath = options.noNaNsFPMath;
36-
approxFuncFPMath = options.approxFuncFPMath;
37-
noSignedZerosFPMath = options.noSignedZerosFPMath;
38-
unsafeFPMath = options.unsafeFPMath;
39-
}
40-
FunctionAttrPass() {}
30+
FunctionAttrPass(const fir::FunctionAttrOptions &options) : Base{options} {}
31+
FunctionAttrPass() = default;
4132
void runOnOperation() override;
4233
};
4334

@@ -56,14 +47,28 @@ void FunctionAttrPass::runOnOperation() {
5647
if ((isFromModule || !func.isDeclaration()) &&
5748
!fir::hasBindcAttr(func.getOperation())) {
5849
llvm::StringRef nocapture = mlir::LLVM::LLVMDialect::getNoCaptureAttrName();
50+
llvm::StringRef noalias = mlir::LLVM::LLVMDialect::getNoAliasAttrName();
5951
mlir::UnitAttr unitAttr = mlir::UnitAttr::get(func.getContext());
6052

6153
for (auto [index, argType] : llvm::enumerate(func.getArgumentTypes())) {
54+
bool isNoCapture = false;
55+
bool isNoAlias = false;
6256
if (mlir::isa<fir::ReferenceType>(argType) &&
6357
!func.getArgAttr(index, fir::getTargetAttrName()) &&
6458
!func.getArgAttr(index, fir::getAsynchronousAttrName()) &&
65-
!func.getArgAttr(index, fir::getVolatileAttrName()))
59+
!func.getArgAttr(index, fir::getVolatileAttrName())) {
60+
isNoCapture = true;
61+
isNoAlias = !fir::isPointerType(argType);
62+
} else if (mlir::isa<fir::BaseBoxType>(argType)) {
63+
// !fir.box arguments will be passed as descriptor pointers
64+
// at LLVM IR dialect level - they cannot be captured,
65+
// and cannot alias with anything within the function.
66+
isNoCapture = isNoAlias = true;
67+
}
68+
if (isNoCapture && setNoCapture)
6669
func.setArgAttr(index, nocapture, unitAttr);
70+
if (isNoAlias && setNoAlias)
71+
func.setArgAttr(index, noalias, unitAttr);
6772
}
6873
}
6974

flang/test/Fir/array-coor.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func.func @test_array_coor_box_component_slice(%arg0: !fir.box<!fir.array<2x!fir
3333
func.func private @take_int(%arg0: !fir.ref<i32>) -> ()
3434

3535
// CHECK-LABEL: define void @test_array_coor_box_component_slice(
36-
// CHECK-SAME: ptr %[[VAL_0:.*]])
36+
// CHECK-SAME: ptr {{[^%]*}}%[[VAL_0:.*]])
3737
// CHECK: %[[VAL_1:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]], ptr, [1 x i64] }, ptr %[[VAL_0]], i32 0, i32 7, i32 0, i32 2
3838
// CHECK: %[[VAL_2:.*]] = load i64, ptr %[[VAL_1]]
3939
// CHECK: %[[VAL_3:.*]] = mul nsw i64 1, %[[VAL_2]]

flang/test/Fir/arrayset.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: tco %s | FileCheck %s
22
// RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
33

4-
// CHECK-LABEL: define void @x(ptr captures(none) %0)
4+
// CHECK-LABEL: define void @x(
55
func.func @x(%arr : !fir.ref<!fir.array<10xf32>>) {
66
%1 = arith.constant 0 : index
77
%2 = arith.constant 9 : index

flang/test/Fir/arrexp.fir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: tco %s | FileCheck %s
22

33
// CHECK-LABEL: define void @f1
4-
// CHECK: (ptr captures(none) %[[A:[^,]*]], {{.*}}, float %[[F:.*]])
4+
// CHECK: (ptr {{[^%]*}}%[[A:[^,]*]], {{.*}}, float %[[F:.*]])
55
func.func @f1(%a : !fir.ref<!fir.array<?x?xf32>>, %n : index, %m : index, %o : index, %p : index, %f : f32) {
66
%c1 = arith.constant 1 : index
77
%s = fir.shape_shift %o, %n, %p, %m : (index, index, index, index) -> !fir.shapeshift<2>
@@ -23,7 +23,7 @@ func.func @f1(%a : !fir.ref<!fir.array<?x?xf32>>, %n : index, %m : index, %o : i
2323
}
2424

2525
// CHECK-LABEL: define void @f2
26-
// CHECK: (ptr captures(none) %[[A:[^,]*]], {{.*}}, float %[[F:.*]])
26+
// CHECK: (ptr {{[^%]*}}%[[A:[^,]*]], {{.*}}, float %[[F:.*]])
2727
func.func @f2(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf32>>, %n : index, %m : index, %o : index, %p : index, %f : f32) {
2828
%c1 = arith.constant 1 : index
2929
%s = fir.shape_shift %o, %n, %p, %m : (index, index, index, index) -> !fir.shapeshift<2>
@@ -47,7 +47,7 @@ func.func @f2(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf
4747
}
4848

4949
// CHECK-LABEL: define void @f3
50-
// CHECK: (ptr captures(none) %[[A:[^,]*]], {{.*}}, float %[[F:.*]])
50+
// CHECK: (ptr {{[^%]*}}%[[A:[^,]*]], {{.*}}, float %[[F:.*]])
5151
func.func @f3(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf32>>, %n : index, %m : index, %o : index, %p : index, %f : f32) {
5252
%c1 = arith.constant 1 : index
5353
%s = fir.shape_shift %o, %n, %p, %m : (index, index, index, index) -> !fir.shapeshift<2>
@@ -72,7 +72,7 @@ func.func @f3(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf
7272
}
7373

7474
// CHECK-LABEL: define void @f4
75-
// CHECK: (ptr captures(none) %[[A:[^,]*]], {{.*}}, float %[[F:.*]])
75+
// CHECK: (ptr {{[^%]*}}%[[A:[^,]*]], {{.*}}, float %[[F:.*]])
7676
func.func @f4(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf32>>, %n : index, %m : index, %o : index, %p : index, %f : f32) {
7777
%c1 = arith.constant 1 : index
7878
%s = fir.shape_shift %o, %n, %p, %m : (index, index, index, index) -> !fir.shapeshift<2>
@@ -102,7 +102,7 @@ func.func @f4(%a : !fir.ref<!fir.array<?x?xf32>>, %b : !fir.ref<!fir.array<?x?xf
102102
// `a = b + f`, with and v assumed shapes.
103103
// Tests that the stride from the descriptor is used.
104104
// CHECK-LABEL: define void @f5
105-
// CHECK: (ptr %[[A:.*]], ptr %[[B:.*]], float %[[F:.*]])
105+
// CHECK: (ptr {{[^%]*}}%[[A:.*]], ptr {{[^%]*}}%[[B:.*]], float %[[F:.*]])
106106
func.func @f5(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: !fir.box<!fir.array<?xf32>>, %arg2: f32) {
107107
%c0 = arith.constant 0 : index
108108
%c1 = arith.constant 1 : index
@@ -135,7 +135,7 @@ func.func @f5(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: !fir.box<!fir.array<?xf
135135
// contiguous array (e.g. `a(2:10:1) = a(1:9:1) + f`, with a assumed shape).
136136
// Test that a temp is created.
137137
// CHECK-LABEL: define void @f6
138-
// CHECK: (ptr %[[A:[^,]*]], float %[[F:.*]])
138+
// CHECK: (ptr {{[^%]*}}%[[A:[^,]*]], float %[[F:.*]])
139139
func.func @f6(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: f32) {
140140
%c0 = arith.constant 0 : index
141141
%c1 = arith.constant 1 : index
@@ -165,7 +165,7 @@ func.func @f6(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: f32) {
165165
// Non contiguous array with lower bounds (x = y(100), with y(4:))
166166
// Test array_coor offset computation.
167167
// CHECK-LABEL: define void @f7(
168-
// CHECK: ptr captures(none) %[[X:[^,]*]], ptr %[[Y:.*]])
168+
// CHECK: ptr {{[^%]*}}%[[X:[^,]*]], ptr {{[^%]*}}%[[Y:.*]])
169169
func.func @f7(%arg0: !fir.ref<f32>, %arg1: !fir.box<!fir.array<?xf32>>) {
170170
%c4 = arith.constant 4 : index
171171
%c100 = arith.constant 100 : index
@@ -181,7 +181,7 @@ func.func @f7(%arg0: !fir.ref<f32>, %arg1: !fir.box<!fir.array<?xf32>>) {
181181

182182
// Test A(:, :)%x reference codegen with A constant shape.
183183
// CHECK-LABEL: define void @f8(
184-
// CHECK-SAME: ptr captures(none) %[[A:.*]], i32 %[[I:.*]])
184+
// CHECK-SAME: ptr {{[^%]*}}%[[A:.*]], i32 %[[I:.*]])
185185
func.func @f8(%a : !fir.ref<!fir.array<2x2x!fir.type<t{i:i32}>>>, %i : i32) {
186186
%c0 = arith.constant 0 : index
187187
%c1 = arith.constant 1 : index
@@ -198,7 +198,7 @@ func.func @f8(%a : !fir.ref<!fir.array<2x2x!fir.type<t{i:i32}>>>, %i : i32) {
198198

199199
// Test casts in in array_coor offset computation when type parameters are not i64
200200
// CHECK-LABEL: define ptr @f9(
201-
// CHECK-SAME: i32 %[[I:.*]], i64 %{{.*}}, i64 %{{.*}}, ptr captures(none) %[[C:.*]])
201+
// CHECK-SAME: i32 %[[I:.*]], i64 %{{.*}}, i64 %{{.*}}, ptr {{[^%]*}}%[[C:.*]])
202202
func.func @f9(%i: i32, %e : i64, %j: i64, %c: !fir.ref<!fir.array<?x?x!fir.char<1,?>>>) -> !fir.ref<!fir.char<1,?>> {
203203
%s = fir.shape %e, %e : (i64, i64) -> !fir.shape<2>
204204
// CHECK: %[[CAST:.*]] = sext i32 %[[I]] to i64

flang/test/Fir/box-offset-codegen.fir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ func.func @scalar_addr(%scalar : !fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm_
77
return %addr : !fir.llvm_ptr<!fir.ref<!fir.type<t>>>
88
}
99
// CHECK-LABEL: define ptr @scalar_addr(
10-
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
10+
// CHECK-SAME: ptr {{[^%]*}}%[[BOX:.*]]){{.*}}{
1111
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 0
1212
// CHECK: ret ptr %[[VAL_0]]
1313

@@ -16,7 +16,7 @@ func.func @scalar_tdesc(%scalar : !fir.ref<!fir.box<!fir.type<t>>>) -> !fir.llvm
1616
return %tdesc : !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
1717
}
1818
// CHECK-LABEL: define ptr @scalar_tdesc(
19-
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
19+
// CHECK-SAME: ptr {{[^%]*}}%[[BOX:.*]]){{.*}}{
2020
// CHECK: %[[VAL_0:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, ptr, [1 x i64] }, ptr %[[BOX]], i32 0, i32 7
2121
// CHECK: ret ptr %[[VAL_0]]
2222

@@ -25,7 +25,7 @@ func.func @array_addr(%array : !fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.ty
2525
return %addr : !fir.llvm_ptr<!fir.ptr<!fir.array<?x!fir.type<t>>>>
2626
}
2727
// CHECK-LABEL: define ptr @array_addr(
28-
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
28+
// CHECK-SAME: ptr {{[^%]*}}%[[BOX:.*]]){{.*}}{
2929
// 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
3030
// CHECK: ret ptr %[[VAL_0]]
3131

@@ -34,6 +34,6 @@ func.func @array_tdesc(%array : !fir.ref<!fir.class<!fir.ptr<!fir.array<?x!fir.t
3434
return %tdesc : !fir.llvm_ptr<!fir.tdesc<!fir.type<t>>>
3535
}
3636
// CHECK-LABEL: define ptr @array_tdesc(
37-
// CHECK-SAME: ptr captures(none) %[[BOX:.*]]){{.*}}{
37+
// CHECK-SAME: ptr {{[^%]*}}%[[BOX:.*]]){{.*}}{
3838
// 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
3939
// CHECK: ret ptr %[[VAL_0]]

flang/test/Fir/box-typecode.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ func.func @test_box_typecode(%a: !fir.class<none>) -> i32 {
66
}
77

88
// CHECK-LABEL: @test_box_typecode(
9-
// CHECK-SAME: ptr %[[BOX:.*]])
9+
// CHECK-SAME: ptr {{[^%]*}}%[[BOX:.*]])
1010
// CHECK: %[[GEP:.*]] = getelementptr { ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}} }, ptr %[[BOX]], i32 0, i32 4
1111
// CHECK: %[[TYPE_CODE:.*]] = load i8, ptr %[[GEP]]
1212
// CHECK: %[[TYPE_CODE_CONV:.*]] = sext i8 %[[TYPE_CODE]] to i32

flang/test/Fir/box.fir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func.func private @g(%b : !fir.box<f32>)
2424
func.func private @ga(%b : !fir.box<!fir.array<?xf32>>)
2525

2626
// CHECK-LABEL: define void @f
27-
// CHECK: (ptr captures(none) %[[ARG:.*]])
27+
// CHECK: (ptr {{[^%]*}}%[[ARG:.*]])
2828
func.func @f(%a : !fir.ref<f32>) {
2929
// CHECK: %[[DESC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
3030
// CHECK: %[[INS0:.*]] = insertvalue {{.*}} { ptr undef, i64 4, i32 20240719, i8 0, i8 27, i8 0, i8 0 }, ptr %[[ARG]], 0
@@ -38,7 +38,7 @@ func.func @f(%a : !fir.ref<f32>) {
3838
}
3939

4040
// CHECK-LABEL: define void @fa
41-
// CHECK: (ptr captures(none) %[[ARG:.*]])
41+
// CHECK: (ptr {{[^%]*}}%[[ARG:.*]])
4242
func.func @fa(%a : !fir.ref<!fir.array<100xf32>>) {
4343
%c = fir.convert %a : (!fir.ref<!fir.array<100xf32>>) -> !fir.ref<!fir.array<?xf32>>
4444
%c1 = arith.constant 1 : index
@@ -54,7 +54,7 @@ func.func @fa(%a : !fir.ref<!fir.array<100xf32>>) {
5454

5555
// Boxing of a scalar character of dynamic length
5656
// CHECK-LABEL: define void @b1(
57-
// CHECK-SAME: ptr captures(none) %[[res:.*]], ptr captures(none) %[[arg0:.*]], i64 %[[arg1:.*]])
57+
// CHECK-SAME: ptr {{[^%]*}}%[[res:.*]], ptr {{[^%]*}}%[[arg0:.*]], i64 %[[arg1:.*]])
5858
func.func @b1(%arg0 : !fir.ref<!fir.char<1,?>>, %arg1 : index) -> !fir.box<!fir.char<1,?>> {
5959
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
6060
// CHECK: %[[size:.*]] = mul i64 1, %[[arg1]]
@@ -69,8 +69,8 @@ func.func @b1(%arg0 : !fir.ref<!fir.char<1,?>>, %arg1 : index) -> !fir.box<!fir.
6969

7070
// Boxing of a dynamic array of character with static length (5)
7171
// CHECK-LABEL: define void @b2(
72-
// CHECK-SAME: ptr captures(none) %[[res]],
73-
// CHECK-SAME: ptr captures(none) %[[arg0:.*]], i64 %[[arg1:.*]])
72+
// CHECK-SAME: ptr {{[^%]*}}%[[res]],
73+
// CHECK-SAME: ptr {{[^%]*}}%[[arg0:.*]], i64 %[[arg1:.*]])
7474
func.func @b2(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,5>>>, %arg1 : index) -> !fir.box<!fir.array<?x!fir.char<1,5>>> {
7575
%1 = fir.shape %arg1 : (index) -> !fir.shape<1>
7676
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
@@ -85,7 +85,7 @@ func.func @b2(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,5>>>, %arg1 : index) ->
8585

8686
// Boxing of a dynamic array of character of dynamic length
8787
// CHECK-LABEL: define void @b3(
88-
// CHECK-SAME: ptr captures(none) %[[res:.*]], ptr captures(none) %[[arg0:.*]], i64 %[[arg1:.*]], i64 %[[arg2:.*]])
88+
// CHECK-SAME: ptr {{[^%]*}}%[[res:.*]], ptr {{[^%]*}}%[[arg0:.*]], i64 %[[arg1:.*]], i64 %[[arg2:.*]])
8989
func.func @b3(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,?>>>, %arg1 : index, %arg2 : index) -> !fir.box<!fir.array<?x!fir.char<1,?>>> {
9090
%1 = fir.shape %arg2 : (index) -> !fir.shape<1>
9191
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
@@ -103,7 +103,7 @@ func.func @b3(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,?>>>, %arg1 : index, %ar
103103

104104
// Boxing of a static array of character of dynamic length
105105
// CHECK-LABEL: define void @b4(
106-
// CHECK-SAME: ptr captures(none) %[[res:.*]], ptr captures(none) %[[arg0:.*]], i64 %[[arg1:.*]])
106+
// CHECK-SAME: ptr {{[^%]*}}%[[res:.*]], ptr {{[^%]*}}%[[arg0:.*]], i64 %[[arg1:.*]])
107107
func.func @b4(%arg0 : !fir.ref<!fir.array<7x!fir.char<1,?>>>, %arg1 : index) -> !fir.box<!fir.array<7x!fir.char<1,?>>> {
108108
%c_7 = arith.constant 7 : index
109109
%1 = fir.shape %c_7 : (index) -> !fir.shape<1>
@@ -122,7 +122,7 @@ func.func @b4(%arg0 : !fir.ref<!fir.array<7x!fir.char<1,?>>>, %arg1 : index) ->
122122

123123
// Storing a fir.box into a fir.ref<fir.box> (modifying descriptors).
124124
// CHECK-LABEL: define void @b5(
125-
// CHECK-SAME: ptr captures(none) %[[arg0:.*]], ptr %[[arg1:.*]])
125+
// CHECK-SAME: ptr {{[^%]*}}%[[arg0:.*]], ptr {{[^%]*}}%[[arg1:.*]])
126126
func.func @b5(%arg0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, %arg1 : !fir.box<!fir.heap<!fir.array<?x?xf32>>>) {
127127
fir.store %arg1 to %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
128128
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %0, ptr %1, i32 72, i1 false)
@@ -132,7 +132,7 @@ func.func @b5(%arg0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, %arg1
132132
func.func private @callee6(!fir.box<none>) -> i32
133133

134134
// CHECK-LABEL: define i32 @box6(
135-
// CHECK-SAME: ptr captures(none) %[[ARG0:.*]], i64 %[[ARG1:.*]], i64 %[[ARG2:.*]])
135+
// CHECK-SAME: ptr {{[^%]*}}%[[ARG0:.*]], i64 %[[ARG1:.*]], i64 %[[ARG2:.*]])
136136
func.func @box6(%0 : !fir.ref<!fir.array<?x?x?x?xf32>>, %1 : index, %2 : index) -> i32 {
137137
%c100 = arith.constant 100 : index
138138
%c50 = arith.constant 50 : index

flang/test/Fir/boxproc.fir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// CHECK: call void @_QPtest_proc_dummy_other(ptr %[[VAL_6]])
1717

1818
// CHECK-LABEL: define void @_QFtest_proc_dummyPtest_proc_dummy_a(ptr
19-
// CHECK-SAME: captures(none) %[[VAL_0:.*]], ptr nest captures(none) %[[VAL_1:.*]])
19+
// CHECK-SAME: {{[^%]*}}%[[VAL_0:.*]], ptr nest {{[^%]*}}%[[VAL_1:.*]])
2020

2121
// CHECK-LABEL: define void @_QPtest_proc_dummy_other(ptr
2222
// CHECK-SAME: %[[VAL_0:.*]])
@@ -92,7 +92,7 @@ func.func @_QPtest_proc_dummy_other(%arg0: !fir.boxproc<() -> ()>) {
9292
// CHECK: call void @llvm.stackrestore.p0(ptr %[[VAL_27]])
9393

9494
// CHECK-LABEL: define { ptr, i64 } @_QFtest_proc_dummy_charPgen_message(ptr
95-
// CHECK-SAME: captures(none) %[[VAL_0:.*]], i64 %[[VAL_1:.*]], ptr nest captures(none) %[[VAL_2:.*]])
95+
// CHECK-SAME: {{[^%]*}}%[[VAL_0:.*]], i64 %[[VAL_1:.*]], ptr nest {{[^%]*}}%[[VAL_2:.*]])
9696
// CHECK: %[[VAL_3:.*]] = getelementptr { { ptr, i64 } }, ptr %[[VAL_2]], i32 0, i32 0
9797
// CHECK: %[[VAL_4:.*]] = load { ptr, i64 }, ptr %[[VAL_3]], align 8
9898
// CHECK: %[[VAL_5:.*]] = extractvalue { ptr, i64 } %[[VAL_4]], 0

flang/test/Fir/commute.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func.func @f1(%a : i32, %b : i32) -> i32 {
1111
return %3 : i32
1212
}
1313

14-
// CHECK-LABEL: define i32 @f2(ptr captures(none) %0)
14+
// CHECK-LABEL: define i32 @f2(ptr {{[^%]*}}%0)
1515
func.func @f2(%a : !fir.ref<i32>) -> i32 {
1616
%1 = fir.load %a : !fir.ref<i32>
1717
// CHECK: %[[r2:.*]] = load

flang/test/Fir/coordinateof.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func.func @foo5(%box : !fir.box<!fir.ptr<!fir.array<?xi32>>>, %i : index) -> i32
6262
}
6363

6464
// CHECK-LABEL: @foo6
65-
// CHECK-SAME: (ptr %[[box:.*]], i64 %{{.*}}, ptr captures(none) %{{.*}})
65+
// CHECK-SAME: (ptr {{[^%]*}}%[[box:.*]], i64 %{{.*}}, ptr {{[^%]*}}%{{.*}})
6666
func.func @foo6(%box : !fir.box<!fir.ptr<!fir.array<?x!fir.char<1>>>>, %i : i64 , %res : !fir.ref<!fir.char<1>>) {
6767
// CHECK: %[[addr_gep:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[box]], i32 0, i32 0
6868
// CHECK: %[[addr:.*]] = load ptr, ptr %[[addr_gep]]

flang/test/Fir/embox.fir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %flang_fc1 -mmlir -disable-external-name-interop -emit-llvm %s -o -| FileCheck %s
33

44

5-
// CHECK-LABEL: define void @_QPtest_callee(ptr %0)
5+
// CHECK-LABEL: define void @_QPtest_callee(
66
func.func @_QPtest_callee(%arg0: !fir.box<!fir.array<?xi32>>) {
77
return
88
}
@@ -29,7 +29,7 @@ func.func @_QPtest_slice() {
2929
return
3030
}
3131

32-
// CHECK-LABEL: define void @_QPtest_dt_callee(ptr %0)
32+
// CHECK-LABEL: define void @_QPtest_dt_callee(
3333
func.func @_QPtest_dt_callee(%arg0: !fir.box<!fir.array<?xi32>>) {
3434
return
3535
}
@@ -63,7 +63,7 @@ func.func @_QPtest_dt_slice() {
6363
func.func private @takesRank2CharBox(!fir.box<!fir.array<?x?x!fir.char<1,?>>>)
6464

6565
// CHECK-LABEL: define void @emboxSubstring(
66-
// CHECK-SAME: ptr captures(none) %[[arg0:.*]])
66+
// CHECK-SAME: ptr {{[^%]*}}%[[arg0:.*]])
6767
func.func @emboxSubstring(%arg0: !fir.ref<!fir.array<2x3x!fir.char<1,4>>>) {
6868
%c2 = arith.constant 2 : index
6969
%c3 = arith.constant 3 : index
@@ -84,7 +84,7 @@ func.func @emboxSubstring(%arg0: !fir.ref<!fir.array<2x3x!fir.char<1,4>>>) {
8484

8585
func.func private @do_something(!fir.box<!fir.array<?xf32>>) -> ()
8686
// CHECK: define void @fir_dev_issue_1416
87-
// CHECK-SAME: ptr captures(none) %[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])
87+
// CHECK-SAME: ptr {{[^%]*}}%[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])
8888
func.func @fir_dev_issue_1416(%arg0: !fir.ref<!fir.array<40x?xf32>>, %low: index, %up: index, %at : index) {
8989
// Test fir.embox with a constant interior array shape.
9090
%c1 = arith.constant 1 : index

0 commit comments

Comments
 (0)