Skip to content

Commit 0dc4614

Browse files
committed
Revert "[flang] Make 'this_image()' an intrinsic function"
This reverts commit 81f8ad1. This seems to break the shared libs build (linaro-flang-aarch64-sharedlibs bot) with: undefined reference to `Fortran::semantics::IsCoarray(Fortran::semantics::Symbol const&) (from tools/flang/lib/Evaluate/CMakeFiles/obj.FortranEvaluate.dir/tools.cpp.o) When linking lib/libFortranEvaluate.so.14git
1 parent a32300a commit 0dc4614

File tree

6 files changed

+4
-67
lines changed

6 files changed

+4
-67
lines changed

flang/docs/Intrinsics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ This phase currently supports all the intrinsic procedures listed above but the
746746

747747
| Intrinsic Category | Intrinsic Procedures Lacking Support |
748748
| --- | --- |
749-
| Coarray intrinsic functions | LCOBOUND, UCOBOUND, FAILED_IMAGES, GET_TEAM, IMAGE_INDEX, STOPPED_IMAGES, TEAM_NUMBER, COSHAPE |
749+
| Coarray intrinsic functions | LCOBOUND, UCOBOUND, FAILED_IMAGES, GET_TEAM, IMAGE_INDEX, STOPPED_IMAGES, TEAM_NUMBER, THIS_IMAGE, COSHAPE |
750750
| Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
751751
| Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
752752
| Non-standard intrinsic functions | AND, OR, XOR, LSHIFT, RSHIFT, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, DCMPLX, EQV, NEQV, INT8, JINT, JNINT, KNINT, LOC, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC |

flang/include/flang/Evaluate/tools.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ template <typename A> bool IsAssumedRank(const std::optional<A> &x) {
8989
return x && IsAssumedRank(*x);
9090
}
9191

92-
// Predicate: true when an expression is a coarray (corank > 0)
93-
bool IsCoarray(const ActualArgument &);
94-
template <typename A> bool IsCoarray(const A &) { return false; }
95-
template <typename A> bool IsCoarray(const Designator<A> &designator) {
96-
if (const auto *symbol{std::get_if<SymbolRef>(&designator.u)}) {
97-
return IsCoarray(symbol->get());
98-
} else {
99-
return false;
100-
}
101-
}
102-
template <typename T> bool IsCoarray(const Expr<T> &expr) {
103-
return std::visit([](const auto &x) { return IsCoarray(x); }, expr.u);
104-
}
105-
template <typename A> bool IsCoarray(const std::optional<A> &x) {
106-
return x && IsCoarray(*x);
107-
}
108-
10992
// Generalizing packagers: these take operations and expressions of more
11093
// specific types and wrap them in Expr<> containers of more abstract types.
11194

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "flang/Evaluate/shape.h"
1717
#include "flang/Evaluate/tools.h"
1818
#include "flang/Evaluate/type.h"
19-
#include "flang/Semantics/tools.h"
2019
#include "llvm/Support/raw_ostream.h"
2120
#include <algorithm>
2221
#include <map>
@@ -177,7 +176,6 @@ ENUM_CLASS(Rank,
177176
shape, // INTEGER vector of known length and no negative element
178177
matrix,
179178
array, // not scalar, rank is known and greater than zero
180-
coarray, // rank is known and can be scalar; has nonzero corank
181179
known, // rank is known and can be scalar
182180
anyOrAssumedRank, // rank can be unknown; assumed-type TYPE(*) allowed
183181
conformable, // scalar, or array of same rank & shape as "array" argument
@@ -743,12 +741,6 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
743741
{"tan", {{"x", SameFloating}}, SameFloating},
744742
{"tand", {{"x", SameFloating}}, SameFloating},
745743
{"tanh", {{"x", SameFloating}}, SameFloating},
746-
// optional team dummy arguments needed to complete the following
747-
// this_image versions
748-
{"this_image", {{"coarray", AnyData, Rank::coarray}, OptionalDIM},
749-
DefaultInt, Rank::scalar, IntrinsicClass::transformationalFunction},
750-
{"this_image", {}, DefaultInt, Rank::scalar,
751-
IntrinsicClass::transformationalFunction},
752744
{"tiny", {{"x", SameReal, Rank::anyOrAssumedRank}}, SameReal, Rank::scalar,
753745
IntrinsicClass::inquiryFunction},
754746
{"trailz", {{"i", AnyInt}}, DefaultInt},
@@ -822,7 +814,8 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
822814

823815
// TODO: Coarray intrinsic functions
824816
// LCOBOUND, UCOBOUND, FAILED_IMAGES, GET_TEAM, IMAGE_INDEX,
825-
// STOPPED_IMAGES, TEAM_NUMBER, COSHAPE
817+
// STOPPED_IMAGES, TEAM_NUMBER, THIS_IMAGE,
818+
// COSHAPE
826819
// TODO: Non-standard intrinsic functions
827820
// AND, OR, XOR, LSHIFT, RSHIFT, SHIFT, ZEXT, IZEXT,
828821
// COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT,
@@ -1427,15 +1420,6 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
14271420
argOk &= rank == arrayArg->Rank();
14281421
}
14291422
break;
1430-
case Rank::coarray:
1431-
argOk = IsCoarray(*arg);
1432-
if (!argOk) {
1433-
messages.Say(
1434-
"'coarray=' argument must have corank > 0 for intrinsic '%s'"_err_en_US,
1435-
name);
1436-
return std::nullopt;
1437-
}
1438-
break;
14391423
case Rank::known:
14401424
if (!knownArg) {
14411425
knownArg = arg;
@@ -1650,7 +1634,6 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
16501634
case Rank::elementalOrBOZ:
16511635
case Rank::shape:
16521636
case Rank::array:
1653-
case Rank::coarray:
16541637
case Rank::known:
16551638
case Rank::anyOrAssumedRank:
16561639
case Rank::reduceOperation:

flang/lib/Evaluate/tools.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,6 @@ bool IsAssumedRank(const ActualArgument &arg) {
683683
}
684684
}
685685

686-
bool IsCoarray(const ActualArgument &arg) {
687-
if (const auto *expr{arg.UnwrapExpr()}) {
688-
return IsCoarray(*expr);
689-
} else {
690-
return false;
691-
}
692-
}
693-
694686
bool IsProcedure(const Expr<SomeType> &expr) {
695687
return std::holds_alternative<ProcedureDesignator>(expr.u);
696688
}

flang/test/Semantics/call10.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pure subroutine s13
184184
pure subroutine s14
185185
integer :: img, nimgs, i[*], tmp
186186
! implicit sync all
187+
!ERROR: Procedure 'this_image' referenced in pure subprogram 's14' must be pure too
187188
img = this_image()
188189
nimgs = num_images()
189190
i = img ! i is ready to use

flang/test/Semantics/this_image.f90

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

0 commit comments

Comments
 (0)