@@ -516,16 +516,8 @@ Fortran::lower::genCallOpAndResult(
516516 mlir::Value cast;
517517 auto *context = builder.getContext ();
518518
519- // Special handling for %VAL arguments: internal procedures expect
520- // reference parameters. When %VAL is used, the argument should be
521- // passed by value. Pass the originally loaded value.
522- if (fir::isa_ref_type (snd) && !fir::isa_ref_type (fst.getType ()) &&
523- fir::dyn_cast_ptrEleTy (snd) == fst.getType ()) {
524- auto loadOp = mlir::cast<fir::LoadOp>(fst.getDefiningOp ());
525- mlir::Value originalStorage = loadOp.getMemref ();
526- cast = originalStorage;
527- } else if (mlir::isa<fir::BoxProcType>(snd) &&
528- mlir::isa<mlir::FunctionType>(fst.getType ())) {
519+ if (mlir::isa<fir::BoxProcType>(snd) &&
520+ mlir::isa<mlir::FunctionType>(fst.getType ())) {
529521 mlir::FunctionType funcTy = mlir::FunctionType::get (context, {}, {});
530522 fir::BoxProcType boxProcTy = builder.getBoxProcType (funcTy);
531523 if (mlir::Value host = argumentHostAssocs (converter, fst)) {
@@ -1677,17 +1669,8 @@ void prepareUserCallArguments(
16771669 break ;
16781670 }
16791671 // For %VAL arguments, we should pass the value directly without
1680- // conversion to reference types. If argTy is different from value type,
1681- // it might be due to signature mismatch with internal procedures.
1682- if (argTy == value.getType ())
1683- caller.placeInput (arg, value);
1684- else if (fir::isa_ref_type (argTy) &&
1685- fir::dyn_cast_ptrEleTy (argTy) == value.getType ()) {
1686- auto loadOp = mlir::cast<fir::LoadOp>(value.getDefiningOp ());
1687- mlir::Value originalStorage = loadOp.getMemref ();
1688- caller.placeInput (arg, originalStorage);
1689- } else
1690- caller.placeInput (arg, builder.createConvert (loc, argTy, value));
1672+ // conversion to reference types.
1673+ caller.placeInput (arg, builder.createConvert (loc, argTy, value));
16911674
16921675 } break ;
16931676 case PassBy::BaseAddressValueAttribute:
0 commit comments