Skip to content

Commit 748b17c

Browse files
authored
Revert "[flang] Align runtime info and lowering regarding passing ABIs (#81166)"
This reverts commit b477d39.
1 parent 2f8e37d commit 748b17c

File tree

5 files changed

+31
-55
lines changed

5 files changed

+31
-55
lines changed

flang/include/flang/Evaluate/characteristics.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ struct DummyDataObject {
229229
static std::optional<DummyDataObject> Characterize(
230230
const semantics::Symbol &, FoldingContext &);
231231
bool CanBePassedViaImplicitInterface(std::string *whyNot = nullptr) const;
232-
bool IsPassedByDescriptor(bool isBindC) const;
233232
llvm::raw_ostream &Dump(llvm::raw_ostream &) const;
234233

235234
TypeAndShape type;

flang/lib/Evaluate/characteristics.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -461,30 +461,6 @@ bool DummyDataObject::CanBePassedViaImplicitInterface(
461461
}
462462
}
463463

464-
bool DummyDataObject::IsPassedByDescriptor(bool isBindC) const {
465-
constexpr TypeAndShape::Attrs shapeRequiringBox = {
466-
TypeAndShape::Attr::AssumedShape, TypeAndShape::Attr::DeferredShape,
467-
TypeAndShape::Attr::AssumedRank, TypeAndShape::Attr::Coarray};
468-
if ((attrs & Attrs{Attr::Allocatable, Attr::Pointer}).any()) {
469-
return true;
470-
} else if ((type.attrs() & shapeRequiringBox).any()) {
471-
// Need to pass shape/coshape info in a descriptor.
472-
return true;
473-
} else if (type.type().IsPolymorphic() && !type.type().IsAssumedType()) {
474-
// Need to pass dynamic type info in a descriptor.
475-
return true;
476-
} else if (const auto *derived{GetDerivedTypeSpec(type.type())}) {
477-
if (const semantics::Scope *scope = derived->scope()) {
478-
// Need to pass length type parameters in a descriptor if any.
479-
return scope->IsDerivedTypeWithLengthParameter();
480-
}
481-
} else if (isBindC && type.type().IsAssumedLengthCharacter()) {
482-
// Fortran 2018 18.3.6 point 2 (5)
483-
return true;
484-
}
485-
return false;
486-
}
487-
488464
llvm::raw_ostream &DummyDataObject::Dump(llvm::raw_ostream &o) const {
489465
attrs.Dump(o, EnumToString);
490466
if (intent != common::Intent::Default) {

flang/lib/Lower/CallInterface.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,31 @@ class Fortran::lower::CallInterfaceImpl {
916916
}
917917
}
918918

919+
// Define when an explicit argument must be passed in a fir.box.
920+
bool dummyRequiresBox(
921+
const Fortran::evaluate::characteristics::DummyDataObject &obj,
922+
bool isBindC) {
923+
using ShapeAttr = Fortran::evaluate::characteristics::TypeAndShape::Attr;
924+
using ShapeAttrs = Fortran::evaluate::characteristics::TypeAndShape::Attrs;
925+
constexpr ShapeAttrs shapeRequiringBox = {
926+
ShapeAttr::AssumedShape, ShapeAttr::DeferredShape,
927+
ShapeAttr::AssumedRank, ShapeAttr::Coarray};
928+
if ((obj.type.attrs() & shapeRequiringBox).any())
929+
// Need to pass shape/coshape info in fir.box.
930+
return true;
931+
if (obj.type.type().IsPolymorphic() && !obj.type.type().IsAssumedType())
932+
// Need to pass dynamic type info in fir.box.
933+
return true;
934+
if (const Fortran::semantics::DerivedTypeSpec *derived =
935+
Fortran::evaluate::GetDerivedTypeSpec(obj.type.type()))
936+
if (const Fortran::semantics::Scope *scope = derived->scope())
937+
// Need to pass length type parameters in fir.box if any.
938+
return scope->IsDerivedTypeWithLengthParameter();
939+
if (isBindC && obj.type.type().IsAssumedLengthCharacter())
940+
return true; // Fortran 2018 18.3.6 point 2 (5)
941+
return false;
942+
}
943+
919944
mlir::Type
920945
translateDynamicType(const Fortran::evaluate::DynamicType &dynamicType) {
921946
Fortran::common::TypeCategory cat = dynamicType.category();
@@ -1002,7 +1027,7 @@ class Fortran::lower::CallInterfaceImpl {
10021027
addFirOperand(boxRefType, nextPassedArgPosition(), Property::MutableBox,
10031028
attrs);
10041029
addPassedArg(PassEntityBy::MutableBox, entity, characteristics);
1005-
} else if (obj.IsPassedByDescriptor(isBindC)) {
1030+
} else if (dummyRequiresBox(obj, isBindC)) {
10061031
// Pass as fir.box or fir.class
10071032
if (isValueAttr &&
10081033
!getConverter().getLoweringOptions().getLowerToHighLevelFIR())

flang/lib/Semantics/runtime-type-info.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ void RuntimeTableBuilder::DescribeSpecialProc(
11441144
which = scalarFinalEnum_;
11451145
if (int rank{evaluate::GetRank(typeAndShape.shape())}; rank > 0) {
11461146
which = IntExpr<1>(ToInt64(which).value() + rank);
1147-
if (dummyData.IsPassedByDescriptor(proc->IsBindC())) {
1147+
if (!proc->dummyArguments[0].CanBePassedViaImplicitInterface()) {
11481148
argThatMightBeDescriptor = 1;
11491149
}
11501150
if (!typeAndShape.attrs().test(evaluate::characteristics::
@@ -1187,14 +1187,10 @@ void RuntimeTableBuilder::DescribeSpecialProc(
11871187
break;
11881188
}
11891189
}
1190-
if (argThatMightBeDescriptor != 0) {
1191-
if (const auto *dummyData{
1192-
std::get_if<evaluate::characteristics::DummyDataObject>(
1193-
&proc->dummyArguments.at(argThatMightBeDescriptor - 1).u)}) {
1194-
if (dummyData->IsPassedByDescriptor(proc->IsBindC())) {
1195-
isArgDescriptorSet |= 1 << (argThatMightBeDescriptor - 1);
1196-
}
1197-
}
1190+
if (argThatMightBeDescriptor != 0 &&
1191+
!proc->dummyArguments.at(argThatMightBeDescriptor - 1)
1192+
.CanBePassedViaImplicitInterface()) {
1193+
isArgDescriptorSet |= 1 << (argThatMightBeDescriptor - 1);
11981194
}
11991195
evaluate::StructureConstructorValues values;
12001196
auto index{evaluate::ToInt64(which)};

flang/test/Semantics/typeinfo09.f90

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)