@@ -516,16 +516,8 @@ Fortran::lower::genCallOpAndResult(
516
516
mlir::Value cast;
517
517
auto *context = builder.getContext ();
518
518
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 ())) {
529
521
mlir::FunctionType funcTy = mlir::FunctionType::get (context, {}, {});
530
522
fir::BoxProcType boxProcTy = builder.getBoxProcType (funcTy);
531
523
if (mlir::Value host = argumentHostAssocs (converter, fst)) {
@@ -1677,17 +1669,8 @@ void prepareUserCallArguments(
1677
1669
break ;
1678
1670
}
1679
1671
// 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));
1691
1674
1692
1675
} break ;
1693
1676
case PassBy::BaseAddressValueAttribute:
0 commit comments