Skip to content

Commit d2d576d

Browse files
committed
[flang] dsecnds test: reuse captured defs in call (review feedback)
1 parent 97567ea commit d2d576d

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ struct IntrinsicLibrary {
250250
mlir::Value genCospi(mlir::Type, llvm::ArrayRef<mlir::Value>);
251251
void genDateAndTime(llvm::ArrayRef<fir::ExtendedValue>);
252252
fir::ExtendedValue genDsecnds(mlir::Type resultType,
253-
llvm::ArrayRef<fir::ExtendedValue> args);
253+
llvm::ArrayRef<fir::ExtendedValue> args);
254254
mlir::Value genDim(mlir::Type, llvm::ArrayRef<mlir::Value>);
255255
fir::ExtendedValue genDotProduct(mlir::Type,
256256
llvm::ArrayRef<fir::ExtendedValue>);

flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
4646
std::optional<fir::CharBoxValue> zone, mlir::Value values);
4747

4848
mlir::Value genDsecnds(fir::FirOpBuilder &builder, mlir::Location loc,
49-
mlir::Value refTime);
49+
mlir::Value refTime);
5050

5151
void genEtime(fir::FirOpBuilder &builder, mlir::Location loc,
5252
mlir::Value values, mlir::Value time);

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3949,7 +3949,7 @@ mlir::Value IntrinsicLibrary::genDprod(mlir::Type resultType,
39493949
// Double precision variant of SECNDS (PGI extension)
39503950
fir::ExtendedValue
39513951
IntrinsicLibrary::genDsecnds(mlir::Type resultType,
3952-
llvm::ArrayRef<fir::ExtendedValue> args) {
3952+
llvm::ArrayRef<fir::ExtendedValue> args) {
39533953
assert(args.size() == 1 && "DSECNDS expects one argument");
39543954

39553955
mlir::Value refTime = fir::getBase(args[0]);

flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void fir::runtime::genDateAndTime(fir::FirOpBuilder &builder,
107107
}
108108

109109
mlir::Value fir::runtime::genDsecnds(fir::FirOpBuilder &builder,
110-
mlir::Location loc, mlir::Value refTime) {
110+
mlir::Location loc, mlir::Value refTime) {
111111
auto runtimeFunc =
112112
fir::runtime::getRuntimeFunc<mkRTKey(Dsecnds)>(loc, builder);
113113

flang/test/Lower/Intrinsics/dsecnds.f90

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@ function use_dsecnds(refTime) result(elapsed)
77
elapsed = dsecnds(refTime)
88
end function
99

10-
! Verify filename and line operands are passed into runtime call
10+
! The argument is lowered with hlfir.declare, which returns two results.
11+
! Capture it here to check that the correct SSA value (%...#0)
12+
! is passed to the runtime call later
13+
! CHECK: %[[DECL:.*]]:2 = hlfir.declare %[[arg0]] dummy_scope
14+
15+
! The file name and source line are also lowered and passed as runtime arguments
16+
! Capture the constant line number and convert the file name to i8*.
1117
! CHECK: %[[STRADDR:.*]] = fir.address_of(
1218
! CHECK: %[[LINE:.*]] = arith.constant {{.*}} : i32
1319
! CHECK: %[[FNAME8:.*]] = fir.convert %[[STRADDR]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
1420

15-
! Call the runtime DSECNDS with (refTime, file, line)
16-
! CHECK: %[[CALL:.*]] = fir.call @_FortranADsecnds(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}} : (!fir.ref<f64>, !fir.ref<i8>, i32) -> f64
21+
! Verify the runtime call is made with:
22+
! - the declared refTime value (%[[DECL]]#0)
23+
! - the converted filename
24+
! - the source line constant
25+
! CHECK: %[[CALL:.*]] = fir.call @_FortranADsecnds(%[[DECL]]#0, %[[FNAME8]], %[[LINE]]) {{.*}} : (!fir.ref<f64>, !fir.ref<i8>, i32) -> f64
1726

18-
! Guard: no illegal ref conversion
27+
! Ensure there is no illegal conversion of a value result into a reference
1928
! CHECK-NOT: fir.convert {{.*}} : (f64) -> !fir.ref<f64>
2029

21-
! Function returns f64
30+
! Confirm the function result is returned as a plain f64
2231
! CHECK: return {{.*}} : f64
32+
33+

0 commit comments

Comments
 (0)