Skip to content

Commit 3d1e8e8

Browse files
committed
respond to review comments
1 parent fe4c2f9 commit 3d1e8e8

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

flang/include/flang/Lower/CallInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class CallInterface {
108108
/// implied by Fortran Value attribute.
109109
Value,
110110
/// ValueAttribute means dummy has the the Fortran VALUE attribute.
111-
ValueAttribute
111+
BaseAddressValueAttribute,
112+
CharBoxValueAttribute // BoxChar with VALUE
112113
};
113114
/// Different properties of an entity that can be passed/returned.
114115
/// One-to-One mapping with PassEntityBy but for

flang/lib/Lower/CallInterface.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,15 @@ class Fortran::lower::CallInterfaceImpl {
604604
// Pass as fir.box_char
605605
auto boxCharTy = fir::BoxCharType::get(&mlirContext, dynamicType.kind());
606606
addFirInput(boxCharTy, nextPassedArgPosition(), Property::BoxChar, attrs);
607-
addPassedArg(PassEntityBy::BoxChar, entity, isOptional);
607+
addPassedArg(isValueAttr ? PassEntityBy::CharBoxValueAttribute
608+
: PassEntityBy::BoxChar,
609+
entity, isOptional);
608610
} else {
609611
// Pass as fir.ref
610612
auto refType = fir::ReferenceType::get(type);
611613
addFirInput(refType, nextPassedArgPosition(), Property::BaseAddress,
612614
attrs);
613-
addPassedArg(isValueAttr ? PassEntityBy::ValueAttribute
615+
addPassedArg(isValueAttr ? PassEntityBy::BaseAddressValueAttribute
614616
: PassEntityBy::BaseAddress,
615617
entity, isOptional);
616618
}

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,8 @@ class ScalarExprLowering {
18551855
// Helper for changing the semantics in a given context. Preserves the current
18561856
// semantics which is resumed when the "push" goes out of scope.
18571857
#define PushSemantics(PushVal) \
1858-
[[maybe_unused]] PushSemant pushSemanticsLocalVariable97201(PushVal, semant);
1858+
[[maybe_unused]] auto pushSemanticsLocalVariable97201 = \
1859+
Fortran::common::ScopedSet(semant, PushVal);
18591860

18601861
namespace {
18611862
class ArrayExprLowering {
@@ -2074,7 +2075,7 @@ class ArrayExprLowering {
20742075
}
20752076

20762077
// A procedure reference to a Fortran elemental intrinsic procedure.
2077-
CC genIntrinsicProcRef(
2078+
CC genElementalIntrinsicProcRef(
20782079
const Fortran::evaluate::ProcedureRef &procRef,
20792080
llvm::Optional<mlir::Type> retTy,
20802081
const Fortran::evaluate::SpecificIntrinsic &intrinsic) {
@@ -2129,8 +2130,9 @@ class ArrayExprLowering {
21292130
}
21302131

21312132
// A procedure reference to a user-defined elemental procedure.
2132-
CC genUDProcRef(const Fortran::evaluate::ProcedureRef &procRef,
2133-
llvm::Optional<mlir::Type> retTy) {
2133+
CC genElementalUserDefinedProcRef(
2134+
const Fortran::evaluate::ProcedureRef &procRef,
2135+
llvm::Optional<mlir::Type> retTy) {
21342136
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
21352137

21362138
Fortran::lower::CallerInterface caller(procRef, converter);
@@ -2162,7 +2164,7 @@ class ArrayExprLowering {
21622164
return lambda(iters);
21632165
};
21642166
} break;
2165-
case PassBy::ValueAttribute: {
2167+
case PassBy::BaseAddressValueAttribute: {
21662168
// VALUE attribute or pass-by-reference to a copy semantics. (byval*)
21672169
PushSemantics(ConstituentSemantics::ByValueArg);
21682170
auto lambda = genarr(*expr);
@@ -2177,8 +2179,11 @@ class ArrayExprLowering {
21772179
return lambda(iters);
21782180
};
21792181
} break;
2182+
case PassBy::CharBoxValueAttribute:
2183+
TODO(loc, "CHARACTER, VALUE");
2184+
break;
21802185
case PassBy::BoxChar:
2181-
TODO(loc, "character");
2186+
TODO(loc, "CHARACTER");
21822187
break;
21832188
case PassBy::AddressAndLength:
21842189
TODO(loc, "address and length argument");
@@ -2188,18 +2193,18 @@ class ArrayExprLowering {
21882193
// See C15100 and C15101
21892194
fir::emitFatalError(loc, "cannot be POINTER, ALLOCATABLE");
21902195
default:
2191-
llvm_unreachable("pass by value not handled here");
2196+
llvm_unreachable("pass by ? not handled here");
21922197
break;
21932198
}
21942199
}
21952200

21962201
if (caller.getIfIndirectCallSymbol())
2197-
TODO(loc, "indirect call");
2202+
fir::emitFatalError(loc, "cannot be indirect call");
21982203
auto funcSym = builder.getSymbolRefAttr(caller.getMangledName());
21992204
auto resTys = caller.getFuncOp().getType().getResults();
22002205
if (caller.getFuncOp().getType().getResults() !=
22012206
caller.genFunctionType().getResults())
2202-
TODO(loc, "type adaption");
2207+
fir::emitFatalError(loc, "type mismatch on declared function");
22032208
return [=](IterSpace iters) -> ExtValue {
22042209
llvm::SmallVector<mlir::Value> args;
22052210
for (const auto &cc : operands)
@@ -2217,14 +2222,14 @@ class ArrayExprLowering {
22172222
if (const auto *intrin = procRef.proc().GetSpecificIntrinsic()) {
22182223
// Elemental intrinsic call.
22192224
// The intrinsic procedure is called once per element of the array.
2220-
return genIntrinsicProcRef(procRef, retTy, *intrin);
2225+
return genElementalIntrinsicProcRef(procRef, retTy, *intrin);
22212226
}
22222227
if (ScalarExprLowering::isStatementFunctionCall(procRef))
22232228
fir::emitFatalError(loc, "statement function cannot be elemental");
22242229

22252230
// Elemental call.
22262231
// The procedure is called once per element of the array argument(s).
2227-
return genUDProcRef(procRef, retTy);
2232+
return genElementalUserDefinedProcRef(procRef, retTy);
22282233
}
22292234

22302235
// Transformational call.
@@ -2696,14 +2701,12 @@ class ArrayExprLowering {
26962701
return [=](IterSpace iters) -> ExtValue {
26972702
auto arrFetch = builder.create<fir::ArrayFetchOp>(loc, eleTy, arrLd,
26982703
iters.iterVec());
2699-
auto exv =
2700-
arrayElementToExtendedValue(builder, loc, extMemref, arrFetch);
2701-
auto base = fir::getBase(exv);
2704+
auto base = arrFetch.getResult();
27022705
auto temp = builder.createTemporary(
27032706
loc, base.getType(),
27042707
llvm::ArrayRef<mlir::NamedAttribute>{getAdaptToByRefAttr()});
27052708
builder.create<fir::StoreOp>(loc, base, temp);
2706-
return temp;
2709+
return arrayElementToExtendedValue(builder, loc, extMemref, temp);
27072710
};
27082711
return [=](IterSpace iters) -> ExtValue {
27092712
auto arrFetch =
@@ -2968,17 +2971,6 @@ class ArrayExprLowering {
29682971
}
29692972

29702973
private:
2971-
struct PushSemant {
2972-
PushSemant(ConstituentSemantics newVal, ConstituentSemantics &oldVal)
2973-
: ref{oldVal} {
2974-
saved = oldVal;
2975-
oldVal = newVal;
2976-
}
2977-
~PushSemant() { ref = saved; }
2978-
ConstituentSemantics saved;
2979-
ConstituentSemantics &ref;
2980-
};
2981-
29822974
explicit ArrayExprLowering(Fortran::lower::AbstractConverter &converter,
29832975
Fortran::lower::StatementContext &stmtCtx,
29842976
Fortran::lower::SymMap &symMap,

0 commit comments

Comments
 (0)