Skip to content

Commit 89822ff

Browse files
committed
Revert "[flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (llvm#139131)"
This reverts commit 41aa674. Breaks build: https://lab.llvm.org/buildbot/#/builders/140/builds/22826
1 parent bb0a078 commit 89822ff

15 files changed

+56
-96
lines changed

flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,8 @@ void OpenMPCounterVisitor::Post(const OmpScheduleClause::Kind &c) {
267267
"type=" + std::string{OmpScheduleClause::EnumToString(c)} + ";";
268268
}
269269
void OpenMPCounterVisitor::Post(const OmpDirectiveNameModifier &c) {
270-
clauseDetails += "name_modifier=" +
271-
llvm::omp::getOpenMPDirectiveName(c.v, llvm::omp::FallbackVersion).str() +
272-
";";
270+
clauseDetails +=
271+
"name_modifier=" + llvm::omp::getOpenMPDirectiveName(c.v).str() + ";";
273272
}
274273
void OpenMPCounterVisitor::Post(const OmpClause &c) {
275274
PostClauseCommon(normalize_clause_name(c.source.ToString()));

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "flang/Common/idioms.h"
1818
#include "flang/Common/indirection.h"
1919
#include "flang/Support/Fortran.h"
20-
#include "llvm/Frontend/OpenMP/OMP.h"
2120
#include "llvm/Support/raw_ostream.h"
2221
#include <string>
2322
#include <type_traits>
@@ -546,8 +545,8 @@ class ParseTreeDumper {
546545
NODE(parser, OmpBeginSectionsDirective)
547546
NODE(parser, OmpBlockDirective)
548547
static std::string GetNodeName(const llvm::omp::Directive &x) {
549-
return llvm::Twine("llvm::omp::Directive = ",
550-
llvm::omp::getOpenMPDirectiveName(x, llvm::omp::FallbackVersion))
548+
return llvm::Twine(
549+
"llvm::omp::Directive = ", llvm::omp::getOpenMPDirectiveName(x))
551550
.str();
552551
}
553552
NODE(parser, OmpClause)

flang/include/flang/Parser/unparse.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ namespace llvm {
1818
class raw_ostream;
1919
}
2020

21-
namespace Fortran::common {
22-
class LangOptions;
23-
}
24-
2521
namespace Fortran::evaluate {
2622
struct GenericExprWrapper;
2723
struct GenericAssignmentWrapper;
@@ -51,18 +47,15 @@ struct AnalyzedObjectsAsFortran {
5147
// Converts parsed program (or fragment) to out as Fortran.
5248
template <typename A>
5349
void Unparse(llvm::raw_ostream &out, const A &root,
54-
const common::LangOptions &langOpts, Encoding encoding = Encoding::UTF_8,
55-
bool capitalizeKeywords = true, bool backslashEscapes = true,
56-
preStatementType *preStatement = nullptr,
50+
Encoding encoding = Encoding::UTF_8, bool capitalizeKeywords = true,
51+
bool backslashEscapes = true, preStatementType *preStatement = nullptr,
5752
AnalyzedObjectsAsFortran * = nullptr);
5853

5954
extern template void Unparse(llvm::raw_ostream &out, const Program &program,
60-
const common::LangOptions &langOpts, Encoding encoding,
61-
bool capitalizeKeywords, bool backslashEscapes,
55+
Encoding encoding, bool capitalizeKeywords, bool backslashEscapes,
6256
preStatementType *preStatement, AnalyzedObjectsAsFortran *);
6357
extern template void Unparse(llvm::raw_ostream &out, const Expr &expr,
64-
const common::LangOptions &langOpts, Encoding encoding,
65-
bool capitalizeKeywords, bool backslashEscapes,
58+
Encoding encoding, bool capitalizeKeywords, bool backslashEscapes,
6659
preStatementType *preStatement, AnalyzedObjectsAsFortran *);
6760
} // namespace Fortran::parser
6861

flang/include/flang/Semantics/unparse-with-symbols.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@ namespace llvm {
1616
class raw_ostream;
1717
}
1818

19-
namespace Fortran::common {
20-
class LangOptions;
21-
}
22-
2319
namespace Fortran::parser {
2420
struct Program;
2521
}
2622

2723
namespace Fortran::semantics {
2824
class SemanticsContext;
2925
void UnparseWithSymbols(llvm::raw_ostream &, const parser::Program &,
30-
const common::LangOptions &,
3126
parser::Encoding encoding = parser::Encoding::UTF_8);
3227
void UnparseWithModules(llvm::raw_ostream &, SemanticsContext &,
3328
const parser::Program &,

flang/lib/Frontend/ParserActions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void debugUnparseNoSema(CompilerInstance &ci, llvm::raw_ostream &out) {
119119
auto &parseTree{ci.getParsing().parseTree()};
120120

121121
// TODO: Options should come from CompilerInvocation
122-
Unparse(out, *parseTree, ci.getInvocation().getLangOpts(),
122+
Unparse(out, *parseTree,
123123
/*encoding=*/parser::Encoding::UTF_8,
124124
/*capitalizeKeywords=*/true, /*backslashEscapes=*/false,
125125
/*preStatement=*/nullptr,
@@ -131,7 +131,6 @@ void debugUnparseWithSymbols(CompilerInstance &ci) {
131131
auto &parseTree{*ci.getParsing().parseTree()};
132132

133133
semantics::UnparseWithSymbols(llvm::outs(), parseTree,
134-
ci.getInvocation().getLangOpts(),
135134
/*encoding=*/parser::Encoding::UTF_8);
136135
}
137136

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,9 @@ void ClauseProcessor::processTODO(mlir::Location currentLocation,
200200
auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) {
201201
if (!x)
202202
return;
203-
unsigned version = semaCtx.langOptions().OpenMPVersion;
204203
TODO(currentLocation,
205204
"Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() +
206-
" in " +
207-
llvm::omp::getOpenMPDirectiveName(directive, version).upper() +
205+
" in " + llvm::omp::getOpenMPDirectiveName(directive).upper() +
208206
" construct");
209207
};
210208

flang/lib/Lower/OpenMP/Decomposer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct ConstructDecomposition {
7070
namespace Fortran::lower::omp {
7171
LLVM_DUMP_METHOD llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
7272
const UnitConstruct &uc) {
73-
os << llvm::omp::getOpenMPDirectiveName(uc.id, llvm::omp::FallbackVersion);
73+
os << llvm::omp::getOpenMPDirectiveName(uc.id);
7474
for (auto [index, clause] : llvm::enumerate(uc.clauses)) {
7575
os << (index == 0 ? '\t' : ' ');
7676
os << llvm::omp::getOpenMPClauseName(clause.id);

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,11 +3754,9 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
37543754
item);
37553755
break;
37563756
case llvm::omp::Directive::OMPD_tile:
3757-
case llvm::omp::Directive::OMPD_unroll: {
3758-
unsigned version = semaCtx.langOptions().OpenMPVersion;
3757+
case llvm::omp::Directive::OMPD_unroll:
37593758
TODO(loc, "Unhandled loop directive (" +
3760-
llvm::omp::getOpenMPDirectiveName(dir, version) + ")");
3761-
}
3759+
llvm::omp::getOpenMPDirectiveName(dir) + ")");
37623760
// case llvm::omp::Directive::OMPD_workdistribute:
37633761
case llvm::omp::Directive::OMPD_workshare:
37643762
newOp = genWorkshareOp(converter, symTable, stmtCtx, semaCtx, eval, loc,

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ OmpDirectiveNameParser::directives() const {
125125
void OmpDirectiveNameParser::initTokens(NameWithId *table) const {
126126
for (size_t i{0}, e{llvm::omp::Directive_enumSize}; i != e; ++i) {
127127
auto id{static_cast<llvm::omp::Directive>(i)};
128-
llvm::StringRef name{
129-
llvm::omp::getOpenMPDirectiveName(id, llvm::omp::FallbackVersion)};
128+
llvm::StringRef name{llvm::omp::getOpenMPDirectiveName(id)};
130129
table[i] = std::make_pair(name.str(), id);
131130
}
132131
// Sort the table with respect to the directive name length in a descending

flang/lib/Parser/parse-tree.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "flang/Common/indirection.h"
1212
#include "flang/Parser/tools.h"
1313
#include "flang/Parser/user-state.h"
14-
#include "llvm/Frontend/OpenMP/OMP.h"
1514
#include "llvm/Support/raw_ostream.h"
1615
#include <algorithm>
1716

@@ -306,9 +305,7 @@ std::string OmpTraitSelectorName::ToString() const {
306305
return std::string(EnumToString(v));
307306
},
308307
[&](llvm::omp::Directive d) {
309-
return llvm::omp::getOpenMPDirectiveName(
310-
d, llvm::omp::FallbackVersion)
311-
.str();
308+
return llvm::omp::getOpenMPDirectiveName(d).str();
312309
},
313310
[&](const std::string &s) { //
314311
return s;

flang/lib/Parser/unparse.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "flang/Parser/parse-tree.h"
1818
#include "flang/Parser/tools.h"
1919
#include "flang/Support/Fortran.h"
20-
#include "flang/Support/LangOptions.h"
2120
#include "llvm/Support/raw_ostream.h"
2221
#include <algorithm>
2322
#include <cinttypes>
@@ -28,14 +27,12 @@ namespace Fortran::parser {
2827

2928
class UnparseVisitor {
3029
public:
31-
UnparseVisitor(llvm::raw_ostream &out, const common::LangOptions &langOpts,
32-
int indentationAmount, Encoding encoding, bool capitalize,
33-
bool backslashEscapes, preStatementType *preStatement,
34-
AnalyzedObjectsAsFortran *asFortran)
35-
: out_{out}, langOpts_{langOpts}, indentationAmount_{indentationAmount},
36-
encoding_{encoding}, capitalizeKeywords_{capitalize},
37-
backslashEscapes_{backslashEscapes}, preStatement_{preStatement},
38-
asFortran_{asFortran} {}
30+
UnparseVisitor(llvm::raw_ostream &out, int indentationAmount,
31+
Encoding encoding, bool capitalize, bool backslashEscapes,
32+
preStatementType *preStatement, AnalyzedObjectsAsFortran *asFortran)
33+
: out_{out}, indentationAmount_{indentationAmount}, encoding_{encoding},
34+
capitalizeKeywords_{capitalize}, backslashEscapes_{backslashEscapes},
35+
preStatement_{preStatement}, asFortran_{asFortran} {}
3936

4037
// In nearly all cases, this code avoids defining Boolean-valued Pre()
4138
// callbacks for the parse tree walking framework in favor of two void
@@ -2105,8 +2102,7 @@ class UnparseVisitor {
21052102
Walk(":", std::get<std::optional<OmpReductionCombiner>>(x.t));
21062103
}
21072104
void Unparse(const llvm::omp::Directive &x) {
2108-
unsigned ompVersion{langOpts_.OpenMPVersion};
2109-
Word(llvm::omp::getOpenMPDirectiveName(x, ompVersion).str());
2105+
Word(llvm::omp::getOpenMPDirectiveName(x).str());
21102106
}
21112107
void Unparse(const OmpDirectiveSpecification &x) {
21122108
auto unparseArgs{[&]() {
@@ -2171,8 +2167,7 @@ class UnparseVisitor {
21712167
x.u);
21722168
}
21732169
void Unparse(const OmpDirectiveNameModifier &x) {
2174-
unsigned ompVersion{langOpts_.OpenMPVersion};
2175-
Word(llvm::omp::getOpenMPDirectiveName(x.v, ompVersion));
2170+
Word(llvm::omp::getOpenMPDirectiveName(x.v));
21762171
}
21772172
void Unparse(const OmpIteratorSpecifier &x) {
21782173
Walk(std::get<TypeDeclarationStmt>(x.t));
@@ -3254,7 +3249,6 @@ class UnparseVisitor {
32543249
}
32553250

32563251
llvm::raw_ostream &out_;
3257-
const common::LangOptions &langOpts_;
32583252
int indent_{0};
32593253
const int indentationAmount_{1};
32603254
int column_{1};
@@ -3347,20 +3341,17 @@ void UnparseVisitor::Word(const std::string_view &str) {
33473341
}
33483342

33493343
template <typename A>
3350-
void Unparse(llvm::raw_ostream &out, const A &root,
3351-
const common::LangOptions &langOpts, Encoding encoding,
3344+
void Unparse(llvm::raw_ostream &out, const A &root, Encoding encoding,
33523345
bool capitalizeKeywords, bool backslashEscapes,
33533346
preStatementType *preStatement, AnalyzedObjectsAsFortran *asFortran) {
3354-
UnparseVisitor visitor{out, langOpts, 1, encoding, capitalizeKeywords,
3355-
backslashEscapes, preStatement, asFortran};
3347+
UnparseVisitor visitor{out, 1, encoding, capitalizeKeywords, backslashEscapes,
3348+
preStatement, asFortran};
33563349
Walk(root, visitor);
33573350
visitor.Done();
33583351
}
33593352

3360-
template void Unparse<Program>(llvm::raw_ostream &, const Program &,
3361-
const common::LangOptions &, Encoding, bool, bool, preStatementType *,
3362-
AnalyzedObjectsAsFortran *);
3363-
template void Unparse<Expr>(llvm::raw_ostream &, const Expr &,
3364-
const common::LangOptions &, Encoding, bool, bool, preStatementType *,
3365-
AnalyzedObjectsAsFortran *);
3353+
template void Unparse<Program>(llvm::raw_ostream &, const Program &, Encoding,
3354+
bool, bool, preStatementType *, AnalyzedObjectsAsFortran *);
3355+
template void Unparse<Expr>(llvm::raw_ostream &, const Expr &, Encoding, bool,
3356+
bool, preStatementType *, AnalyzedObjectsAsFortran *);
33663357
} // namespace Fortran::parser

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,8 @@ void OmpStructureChecker::Enter(
24342434
break;
24352435
default:
24362436
context_.Say(dirName.source, "%s is not a cancellable construct"_err_en_US,
2437-
parser::ToUpperCaseLetters(getDirectiveName(dirName.v).str()));
2437+
parser::ToUpperCaseLetters(
2438+
llvm::omp::getOpenMPDirectiveName(dirName.v).str()));
24382439
break;
24392440
}
24402441
}
@@ -2467,7 +2468,7 @@ std::optional<llvm::omp::Directive> OmpStructureChecker::GetCancelType(
24672468
// Given clauses from CANCEL or CANCELLATION_POINT, identify the construct
24682469
// to which the cancellation applies.
24692470
std::optional<llvm::omp::Directive> cancelee;
2470-
llvm::StringRef cancelName{getDirectiveName(cancelDir)};
2471+
llvm::StringRef cancelName{llvm::omp::getOpenMPDirectiveName(cancelDir)};
24712472

24722473
for (const parser::OmpClause &clause : maybeClauses->v) {
24732474
using CancellationConstructType =
@@ -2495,7 +2496,7 @@ std::optional<llvm::omp::Directive> OmpStructureChecker::GetCancelType(
24952496

24962497
void OmpStructureChecker::CheckCancellationNest(
24972498
const parser::CharBlock &source, llvm::omp::Directive type) {
2498-
llvm::StringRef typeName{getDirectiveName(type)};
2499+
llvm::StringRef typeName{llvm::omp::getOpenMPDirectiveName(type)};
24992500

25002501
if (CurrentDirectiveIsNested()) {
25012502
// If construct-type-clause is taskgroup, the cancellation construct must be
@@ -4059,10 +4060,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::If &x) {
40594060
if (auto *dnm{OmpGetUniqueModifier<parser::OmpDirectiveNameModifier>(
40604061
modifiers)}) {
40614062
llvm::omp::Directive sub{dnm->v};
4062-
std::string subName{
4063-
parser::ToUpperCaseLetters(getDirectiveName(sub).str())};
4064-
std::string dirName{
4065-
parser::ToUpperCaseLetters(getDirectiveName(dir).str())};
4063+
std::string subName{parser::ToUpperCaseLetters(
4064+
llvm::omp::getOpenMPDirectiveName(sub).str())};
4065+
std::string dirName{parser::ToUpperCaseLetters(
4066+
llvm::omp::getOpenMPDirectiveName(dir).str())};
40664067

40674068
parser::CharBlock modifierSource{OmpGetModifierSource(modifiers, dnm)};
40684069
auto desc{OmpGetDescriptor<parser::OmpDirectiveNameModifier>()};
@@ -5432,8 +5433,7 @@ llvm::StringRef OmpStructureChecker::getClauseName(llvm::omp::Clause clause) {
54325433

54335434
llvm::StringRef OmpStructureChecker::getDirectiveName(
54345435
llvm::omp::Directive directive) {
5435-
unsigned version{context_.langOptions().OpenMPVersion};
5436-
return llvm::omp::getOpenMPDirectiveName(directive, version);
5436+
return llvm::omp::getOpenMPDirectiveName(directive);
54375437
}
54385438

54395439
const Symbol *OmpStructureChecker::GetObjectSymbol(

flang/lib/Semantics/mod-file.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void CollectSymbols(
5050
const Scope &, SymbolVector &, SymbolVector &, SourceOrderedSymbolSet &);
5151
static void PutPassName(llvm::raw_ostream &, const std::optional<SourceName> &);
5252
static void PutInit(llvm::raw_ostream &, const Symbol &, const MaybeExpr &,
53-
const parser::Expr *, SemanticsContext &);
53+
const parser::Expr *);
5454
static void PutInit(llvm::raw_ostream &, const MaybeIntExpr &);
5555
static void PutBound(llvm::raw_ostream &, const Bound &);
5656
static void PutShapeSpec(llvm::raw_ostream &, const ShapeSpec &);
@@ -605,7 +605,7 @@ void ModFileWriter::PutDECStructure(
605605
}
606606
decls_ << ref->name();
607607
PutShape(decls_, object->shape(), '(', ')');
608-
PutInit(decls_, *ref, object->init(), nullptr, context_);
608+
PutInit(decls_, *ref, object->init(), nullptr);
609609
emittedDECFields_.insert(*ref);
610610
} else if (any) {
611611
break; // any later use of this structure will use RECORD/str/
@@ -944,8 +944,7 @@ void ModFileWriter::PutObjectEntity(
944944
getSymbolAttrsToWrite(symbol));
945945
PutShape(os, details.shape(), '(', ')');
946946
PutShape(os, details.coshape(), '[', ']');
947-
PutInit(os, symbol, details.init(), details.unanalyzedPDTComponentInit(),
948-
context_);
947+
PutInit(os, symbol, details.init(), details.unanalyzedPDTComponentInit());
949948
os << '\n';
950949
if (auto tkr{GetIgnoreTKR(symbol)}; !tkr.empty()) {
951950
os << "!dir$ ignore_tkr(";
@@ -1037,11 +1036,11 @@ void ModFileWriter::PutTypeParam(llvm::raw_ostream &os, const Symbol &symbol) {
10371036
}
10381037

10391038
void PutInit(llvm::raw_ostream &os, const Symbol &symbol, const MaybeExpr &init,
1040-
const parser::Expr *unanalyzed, SemanticsContext &context) {
1039+
const parser::Expr *unanalyzed) {
10411040
if (IsNamedConstant(symbol) || symbol.owner().IsDerivedType()) {
10421041
const char *assign{symbol.attrs().test(Attr::POINTER) ? "=>" : "="};
10431042
if (unanalyzed) {
1044-
parser::Unparse(os << assign, *unanalyzed, context.langOptions());
1043+
parser::Unparse(os << assign, *unanalyzed);
10451044
} else if (init) {
10461045
init->AsFortran(os << assign);
10471046
}

0 commit comments

Comments
 (0)