Skip to content

Commit 4ca111d

Browse files
committed
Revert "[flang] Add & use a better visit()"
This reverts commit 2ab9990. It has caused multiple build failures: * https://lab.llvm.org/buildbot/#/builders/177/builds/4346 * https://lab.llvm.org/buildbot/#/builders/180/builds/3803 * https://lab.llvm.org/buildbot/#/builders/175/builds/10419 * https://lab.llvm.org/buildbot/#/builders/191/builds/4318 * https://lab.llvm.org/buildbot/#/builders/173/builds/4274 * https://lab.llvm.org/buildbot/#/builders/181/builds/4297 All these bots failed with a time-out: ``` command timed out: 1200 seconds without output running [b'ninja', b'-j', b'32'], attempting to kill ``` I'm guessing that that's due to template instantiations failing at some point (https://reviews.llvm.org/D122441 introduced a custom implementation of std::visit). Everything seems fine when either: * building on X86 with GCC or Clang (tested with GCC 9.3 and Clang 12) * building on AArch64 with GCC (tested with GCC 11)
1 parent 8a2a966 commit 4ca111d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1297
-1427
lines changed

flang/include/flang/Common/idioms.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#error g++ >= 7.2 is required
2424
#endif
2525

26-
#include "visit.h"
2726
#include "llvm/Support/Compiler.h"
2827
#include <functional>
2928
#include <list>
@@ -50,8 +49,8 @@ using namespace std::literals::string_literals;
5049
namespace Fortran::common {
5150

5251
// Helper templates for combining a list of lambdas into an anonymous
53-
// struct for use with common::visit() on a std::variant<> sum type.
54-
// E.g.: common::visit(visitors{
52+
// struct for use with std::visit() on a std::variant<> sum type.
53+
// E.g.: std::visit(visitors{
5554
// [&](const firstType &x) { ... },
5655
// [&](const secondType &x) { ... },
5756
// ...

flang/include/flang/Common/template.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ template <typename A> const A *GetPtrFromOptional(const std::optional<A> &x) {
118118
// Copy a value from one variant type to another. The types allowed in the
119119
// source variant must all be allowed in the destination variant type.
120120
template <typename TOV, typename FROMV> TOV CopyVariant(const FROMV &u) {
121-
return common::visit([](const auto &x) -> TOV { return {x}; }, u);
121+
return std::visit([](const auto &x) -> TOV { return {x}; }, u);
122122
}
123123

124124
// Move a value from one variant type to another. The types allowed in the
125125
// source variant must all be allowed in the destination variant type.
126126
template <typename TOV, typename FROMV>
127127
common::IfNoLvalue<TOV, FROMV> MoveVariant(FROMV &&u) {
128-
return common::visit(
128+
return std::visit(
129129
[](auto &&x) -> TOV { return {std::move(x)}; }, std::move(u));
130130
}
131131

flang/include/flang/Common/unwrap.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "indirection.h"
1313
#include "reference-counted.h"
1414
#include "reference.h"
15-
#include "visit.h"
1615
#include <memory>
1716
#include <optional>
1817
#include <type_traits>
@@ -104,7 +103,7 @@ struct UnwrapperHelper {
104103

105104
template <typename A, typename... Bs>
106105
static A *Unwrap(std::variant<Bs...> &u) {
107-
return common::visit(
106+
return std::visit(
108107
[](auto &x) -> A * {
109108
using Ty = std::decay_t<decltype(Unwrap<A>(x))>;
110109
if constexpr (!std::is_const_v<std::remove_pointer_t<Ty>> ||
@@ -118,7 +117,7 @@ struct UnwrapperHelper {
118117

119118
template <typename A, typename... Bs>
120119
static auto Unwrap(const std::variant<Bs...> &u) -> std::add_const_t<A> * {
121-
return common::visit(
120+
return std::visit(
122121
[](const auto &x) -> std::add_const_t<A> * { return Unwrap<A>(x); }, u);
123122
}
124123

flang/include/flang/Common/visit.h

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

flang/include/flang/Evaluate/expression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ template <> class Relational<SomeType> {
646646
EVALUATE_UNION_CLASS_BOILERPLATE(Relational)
647647
static constexpr DynamicType GetType() { return Result::GetType(); }
648648
int Rank() const {
649-
return common::visit([](const auto &x) { return x.Rank(); }, u);
649+
return std::visit([](const auto &x) { return x.Rank(); }, u);
650650
}
651651
llvm::raw_ostream &AsFortran(llvm::raw_ostream &o) const;
652652
common::MapTemplate<Relational, DirectlyComparableTypes> u;

flang/include/flang/Evaluate/fold-designator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class DesignatorFolder {
6767

6868
template <typename T>
6969
std::optional<OffsetSymbol> FoldDesignator(const Expr<T> &expr) {
70-
return common::visit(
70+
return std::visit(
7171
[&](const auto &x) { return FoldDesignator(x, elementNumber_++); },
7272
expr.u);
7373
}
@@ -98,7 +98,7 @@ class DesignatorFolder {
9898
template <typename T>
9999
std::optional<OffsetSymbol> FoldDesignator(
100100
const Expr<T> &expr, ConstantSubscript which) {
101-
return common::visit(
101+
return std::visit(
102102
[&](const auto &x) { return FoldDesignator(x, which); }, expr.u);
103103
}
104104

@@ -110,14 +110,14 @@ class DesignatorFolder {
110110
template <typename T>
111111
std::optional<OffsetSymbol> FoldDesignator(
112112
const Designator<T> &designator, ConstantSubscript which) {
113-
return common::visit(
113+
return std::visit(
114114
[&](const auto &x) { return FoldDesignator(x, which); }, designator.u);
115115
}
116116
template <int KIND>
117117
std::optional<OffsetSymbol> FoldDesignator(
118118
const Designator<Type<TypeCategory::Character, KIND>> &designator,
119119
ConstantSubscript which) {
120-
return common::visit(
120+
return std::visit(
121121
common::visitors{
122122
[&](const Substring &ss) {
123123
if (const auto *dataRef{ss.GetParentIf<DataRef>()}) {

flang/include/flang/Evaluate/initial-image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class InitialImage {
8888
template <typename T>
8989
Result Add(ConstantSubscript offset, std::size_t bytes, const Expr<T> &x,
9090
FoldingContext &c) {
91-
return common::visit(
91+
return std::visit(
9292
[&](const auto &y) { return Add(offset, bytes, y, c); }, x.u);
9393
}
9494

flang/include/flang/Evaluate/shape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class GetShapeHelper
167167
template <typename T>
168168
MaybeExtentExpr GetArrayConstructorValueExtent(
169169
const ArrayConstructorValue<T> &value) const {
170-
return common::visit(
170+
return std::visit(
171171
common::visitors{
172172
[&](const Expr<T> &x) -> MaybeExtentExpr {
173173
if (auto xShape{

flang/include/flang/Evaluate/tools.h

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ template <typename A> bool IsAssumedRank(const Designator<A> &designator) {
8383
}
8484
}
8585
template <typename T> bool IsAssumedRank(const Expr<T> &expr) {
86-
return common::visit([](const auto &x) { return IsAssumedRank(x); }, expr.u);
86+
return std::visit([](const auto &x) { return IsAssumedRank(x); }, expr.u);
8787
}
8888
template <typename A> bool IsAssumedRank(const std::optional<A> &x) {
8989
return x && IsAssumedRank(*x);
@@ -100,7 +100,7 @@ template <typename A> bool IsCoarray(const Designator<A> &designator) {
100100
return false;
101101
}
102102
template <typename T> bool IsCoarray(const Expr<T> &expr) {
103-
return common::visit([](const auto &x) { return IsCoarray(x); }, expr.u);
103+
return std::visit([](const auto &x) { return IsCoarray(x); }, expr.u);
104104
}
105105
template <typename A> bool IsCoarray(const std::optional<A> &x) {
106106
return x && IsCoarray(*x);
@@ -177,11 +177,11 @@ auto UnwrapExpr(B &x) -> common::Constify<A, B> * {
177177
return UnwrapExpr<A>(*expr);
178178
}
179179
} else if constexpr (std::is_same_v<Ty, Expr<SomeType>>) {
180-
return common::visit([](auto &x) { return UnwrapExpr<A>(x); }, x.u);
180+
return std::visit([](auto &x) { return UnwrapExpr<A>(x); }, x.u);
181181
} else if constexpr (!common::HasMember<A, TypelessExpression>) {
182182
if constexpr (std::is_same_v<Ty, Expr<ResultType<A>>> ||
183183
std::is_same_v<Ty, Expr<SomeKind<ResultType<A>::category>>>) {
184-
return common::visit([](auto &x) { return UnwrapExpr<A>(x); }, x.u);
184+
return std::visit([](auto &x) { return UnwrapExpr<A>(x); }, x.u);
185185
}
186186
}
187187
return nullptr;
@@ -217,17 +217,15 @@ auto UnwrapConvertedExpr(B &x) -> common::Constify<A, B> * {
217217
return UnwrapConvertedExpr<A>(*expr);
218218
}
219219
} else if constexpr (std::is_same_v<Ty, Expr<SomeType>>) {
220-
return common::visit(
221-
[](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u);
220+
return std::visit([](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u);
222221
} else if constexpr (!common::HasMember<A, TypelessExpression>) {
223222
using Result = ResultType<A>;
224223
if constexpr (std::is_same_v<Ty, Expr<Result>> ||
225224
std::is_same_v<Ty, Expr<SomeKind<Result::category>>>) {
226-
return common::visit(
227-
[](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u);
225+
return std::visit([](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u);
228226
} else if constexpr (std::is_same_v<Ty, Parentheses<Result>> ||
229227
std::is_same_v<Ty, Convert<Result, Result::category>>) {
230-
return common::visit(
228+
return std::visit(
231229
[](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.left().u);
232230
}
233231
}
@@ -264,7 +262,7 @@ common::IfNoLvalue<std::optional<DataRef>, A> ExtractDataRef(
264262
template <typename T>
265263
std::optional<DataRef> ExtractDataRef(
266264
const Designator<T> &d, bool intoSubstring = false) {
267-
return common::visit(
265+
return std::visit(
268266
[=](const auto &x) -> std::optional<DataRef> {
269267
if constexpr (common::HasMember<decltype(x), decltype(DataRef::u)>) {
270268
return DataRef{x};
@@ -281,7 +279,7 @@ std::optional<DataRef> ExtractDataRef(
281279
template <typename T>
282280
std::optional<DataRef> ExtractDataRef(
283281
const Expr<T> &expr, bool intoSubstring = false) {
284-
return common::visit(
282+
return std::visit(
285283
[=](const auto &x) { return ExtractDataRef(x, intoSubstring); }, expr.u);
286284
}
287285
template <typename A>
@@ -330,7 +328,7 @@ bool IsArrayElement(const Expr<T> &expr, bool intoSubstring = true,
330328
template <typename A>
331329
std::optional<NamedEntity> ExtractNamedEntity(const A &x) {
332330
if (auto dataRef{ExtractDataRef(x, true)}) {
333-
return common::visit(
331+
return std::visit(
334332
common::visitors{
335333
[](SymbolRef &&symbol) -> std::optional<NamedEntity> {
336334
return NamedEntity{symbol};
@@ -356,10 +354,10 @@ struct ExtractCoindexedObjectHelper {
356354
std::optional<CoarrayRef> operator()(const CoarrayRef &x) const { return x; }
357355
template <typename A>
358356
std::optional<CoarrayRef> operator()(const Expr<A> &expr) const {
359-
return common::visit(*this, expr.u);
357+
return std::visit(*this, expr.u);
360358
}
361359
std::optional<CoarrayRef> operator()(const DataRef &dataRef) const {
362-
return common::visit(*this, dataRef.u);
360+
return std::visit(*this, dataRef.u);
363361
}
364362
std::optional<CoarrayRef> operator()(const NamedEntity &named) const {
365363
if (const Component * component{named.UnwrapComponent()}) {
@@ -451,7 +449,7 @@ Expr<TO> ConvertToType(Expr<SomeKind<FROMCAT>> &&x) {
451449
ConvertToType<Part>(std::move(x)), Expr<Part>{Constant<Part>{zero}}}};
452450
} else if constexpr (FROMCAT == TypeCategory::Complex) {
453451
// Extract and convert the real component of a complex value
454-
return common::visit(
452+
return std::visit(
455453
[&](auto &&z) {
456454
using ZType = ResultType<decltype(z)>;
457455
using Part = typename ZType::Part;
@@ -505,7 +503,7 @@ common::IfNoLvalue<Expr<Type<TC, TK>>, FROM> ConvertTo(
505503
template <TypeCategory TC, typename FROM>
506504
common::IfNoLvalue<Expr<SomeKind<TC>>, FROM> ConvertTo(
507505
const Expr<SomeKind<TC>> &to, FROM &&from) {
508-
return common::visit(
506+
return std::visit(
509507
[&](const auto &toKindExpr) {
510508
using KindExpr = std::decay_t<decltype(toKindExpr)>;
511509
return AsCategoryExpr(
@@ -517,7 +515,7 @@ common::IfNoLvalue<Expr<SomeKind<TC>>, FROM> ConvertTo(
517515
template <typename FROM>
518516
common::IfNoLvalue<Expr<SomeType>, FROM> ConvertTo(
519517
const Expr<SomeType> &to, FROM &&from) {
520-
return common::visit(
518+
return std::visit(
521519
[&](const auto &toCatExpr) {
522520
return AsGenericExpr(ConvertTo(toCatExpr, std::move(from)));
523521
},
@@ -567,7 +565,7 @@ using SameKindExprs =
567565
template <TypeCategory CAT>
568566
SameKindExprs<CAT, 2> AsSameKindExprs(
569567
Expr<SomeKind<CAT>> &&x, Expr<SomeKind<CAT>> &&y) {
570-
return common::visit(
568+
return std::visit(
571569
[&](auto &&kx, auto &&ky) -> SameKindExprs<CAT, 2> {
572570
using XTy = ResultType<decltype(kx)>;
573571
using YTy = ResultType<decltype(ky)>;
@@ -628,7 +626,7 @@ Expr<SPECIFIC> Combine(Expr<SPECIFIC> &&x, Expr<SPECIFIC> &&y) {
628626
template <template <typename> class OPR, TypeCategory CAT>
629627
Expr<SomeKind<CAT>> PromoteAndCombine(
630628
Expr<SomeKind<CAT>> &&x, Expr<SomeKind<CAT>> &&y) {
631-
return common::visit(
629+
return std::visit(
632630
[](auto &&xy) {
633631
using Ty = ResultType<decltype(xy[0])>;
634632
return AsCategoryExpr(
@@ -729,7 +727,7 @@ Expr<Type<C, K>> operator/(Expr<Type<C, K>> &&x, Expr<Type<C, K>> &&y) {
729727
}
730728

731729
template <TypeCategory C> Expr<SomeKind<C>> operator-(Expr<SomeKind<C>> &&x) {
732-
return common::visit(
730+
return std::visit(
733731
[](auto &xk) { return Expr<SomeKind<C>>{-std::move(xk)}; }, x.u);
734732
}
735733

@@ -874,7 +872,7 @@ std::optional<BaseObject> GetBaseObject(const Designator<T> &x) {
874872
}
875873
template <typename T>
876874
std::optional<BaseObject> GetBaseObject(const Expr<T> &x) {
877-
return common::visit([](const auto &y) { return GetBaseObject(y); }, x.u);
875+
return std::visit([](const auto &y) { return GetBaseObject(y); }, x.u);
878876
}
879877
template <typename A>
880878
std::optional<BaseObject> GetBaseObject(const std::optional<A> &x) {
@@ -1014,8 +1012,7 @@ class ScalarConstantExpander {
10141012
return Expand(std::move(x.left())); // Constant<> can be parenthesized
10151013
}
10161014
template <typename T> Expr<T> Expand(Expr<T> &&x) {
1017-
return common::visit(
1018-
[&](auto &&x) { return Expr<T>{Expand(std::move(x))}; },
1015+
return std::visit([&](auto &&x) { return Expr<T>{Expand(std::move(x))}; },
10191016
std::move(x.u));
10201017
}
10211018

flang/include/flang/Evaluate/traverse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ template <typename Visitor, typename Result> class Traverse {
7878
}
7979
template <typename... A>
8080
Result operator()(const std::variant<A...> &u) const {
81-
return common::visit(visitor_, u);
81+
return std::visit(visitor_, u);
8282
}
8383
template <typename A> Result operator()(const std::vector<A> &x) const {
8484
return CombineContents(x);

0 commit comments

Comments
 (0)