Skip to content

Commit 1d33514

Browse files
committed
nit fixes for review
1 parent 3d80163 commit 1d33514

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

flang/include/flang/Lower/PFTBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ struct Evaluation : EvaluationVariant {
347347
parser::CharBlock position{};
348348
std::optional<parser::Label> label{};
349349
std::unique_ptr<EvaluationList> evaluationList; // nested evaluations
350-
llvm::SmallVector<const parser::CompilerDirective *> dirs;
350+
// associated compiler directives
351+
llvm::SmallVector<const parser::CompilerDirective *, 1> dirs;
351352
Evaluation *parentConstruct{nullptr}; // set for nodes below the top level
352353
Evaluation *lexicalSuccessor{nullptr}; // set for leaf nodes, some directives
353354
Evaluation *controlSuccessor{nullptr}; // set for some leaf nodes

flang/lib/Lower/Bridge.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,18 +2596,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
25962596
}
25972597
}
25982598

2599-
void attachLoopDirective(const Fortran::parser::CompilerDirective &dir,
2599+
void attachDirectiveToLoop(const Fortran::parser::CompilerDirective &dir,
26002600
Fortran::lower::pft::Evaluation *e) {
2601-
while (e->isDirective()) {
2601+
while (e->isDirective())
26022602
e = e->lexicalSuccessor;
2603-
}
26042603

2605-
if (e->isA<Fortran::parser::NonLabelDoStmt>()) {
2604+
if (e->isA<Fortran::parser::NonLabelDoStmt>())
26062605
e->dirs.push_back(&dir);
2607-
} else {
2606+
else
26082607
fir::emitFatalError(toLocation(),
26092608
"loop directive must appear before a loop");
2610-
}
26112609
}
26122610

26132611
void genFIR(const Fortran::parser::CompilerDirective &dir) {
@@ -2616,7 +2614,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
26162614
std::visit(
26172615
Fortran::common::visitors{
26182616
[&](const Fortran::parser::CompilerDirective::VectorAlways &) {
2619-
attachLoopDirective(dir, &eval);
2617+
attachDirectiveToLoop(dir, &eval);
26202618
},
26212619
[&](const auto &) {}},
26222620
dir.u);

flang/lib/Semantics/resolve-names.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8886,9 +8886,12 @@ void ResolveNamesVisitor::Post(const parser::AssignedGotoStmt &x) {
88868886
}
88878887

88888888
void ResolveNamesVisitor::Post(const parser::CompilerDirective &x) {
8889-
if (const auto *dir{
8890-
std::get_if<parser::CompilerDirective::VectorAlways>(&x.u)})
8889+
//if (const auto *dir{
8890+
// std::get_if<parser::CompilerDirective::VectorAlways>(&x.u)})
8891+
8892+
if (std::holds_alternative<parser::CompilerDirective::VectorAlways>(x.u)) {
88918893
return;
8894+
}
88928895
if (const auto *tkr{
88938896
std::get_if<std::list<parser::CompilerDirective::IgnoreTKR>>(&x.u)}) {
88948897
if (currScope().IsTopLevel() ||

flang/test/Fir/vector-always.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func.func @_QPvector_always() {
1919
%5 = fir.convert %c1_i32 : (i32) -> index
2020
%6 = fir.convert %c10_i32 : (i32) -> index
2121
%7 = fir.convert %5 : (index) -> i32
22-
%8:2 = fir.do_loop %arg0 = %5 to %6 step %c1 iter_args(%arg1 = %7) -> (index, i32) attributes {loop_annotation = #loop_annotation} {
22+
%8:2 = fir.do_loop %arg0 = %5 to %6 step %c1 iter_args(%arg1 = %7) -> (index, i32) attributes {loopAnnotation = #loop_annotation} {
2323
fir.store %arg1 to %4 : !fir.ref<i32>
2424
%9 = fir.load %4 : !fir.ref<i32>
2525
%10 = fir.load %4 : !fir.ref<i32>

flang/test/Lower/vector-always.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
subroutine vector_always
1111
integer :: a(10)
1212
!dir$ vector always
13-
!CHECK: fir.do_loop {{.*}} attributes {loop_annotation = #loop_annotation}
13+
!CHECK: fir.do_loop {{.*}} attributes {loopAnnotation = #loop_annotation}
1414
do i=1,10
1515
a(i)=i
1616
end do
@@ -22,7 +22,7 @@ subroutine intermediate_directive
2222
integer :: a(10)
2323
!dir$ vector always
2424
!dir$ unknown
25-
!CHECK: fir.do_loop {{.*}} attributes {loop_annotation = #loop_annotation1}
25+
!CHECK: fir.do_loop {{.*}} attributes {loopAnnotation = #loop_annotation1}
2626
do i=1,10
2727
a(i)=i
2828
end do

0 commit comments

Comments
 (0)