Skip to content

Commit ab74c1a

Browse files
committed
Use llvm::SmallVector instead of std::stack
1 parent db09c91 commit ab74c1a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

flang/lib/Semantics/canonicalize-omp.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "canonicalize-omp.h"
1010
#include "flang/Parser/parse-tree-visitor.h"
11-
#include <stack>
1211
// After Loop Canonicalization, rewrite OpenMP parse tree to make OpenMP
1312
// Constructs more structured which provide explicit scopes for later
1413
// structural checks and semantic analysis.
@@ -134,8 +133,8 @@ class CanonicalizationOfOmp {
134133
if (GetConstructIf<parser::CompilerDirective>(*nextIt))
135134
continue;
136135
// Keep track of the loops to handle the end loop directives
137-
std::stack<parser::OpenMPLoopConstruct *> loops;
138-
loops.push(&x);
136+
llvm::SmallVector<parser::OpenMPLoopConstruct *> loops;
137+
loops.push_back(&x);
139138
if (auto *innerConstruct{
140139
GetConstructIf<parser::OpenMPConstruct>(*nextIt)}) {
141140
if (auto *innerOmpLoop{
@@ -146,12 +145,12 @@ class CanonicalizationOfOmp {
146145
if (innerDir.v == llvm::omp::Directive::OMPD_tile) {
147146
std::get<std::optional<
148147
common::Indirection<parser::OpenMPLoopConstruct>>>(
149-
loops.top()->t) = std::move(*innerOmpLoop);
148+
loops.back()->t) = std::move(*innerOmpLoop);
150149
// Retrieveing the address so that DoConstruct or inner loop can be
151150
// set later.
152-
loops.push(&(std::get<std::optional<
151+
loops.push_back(&(std::get<std::optional<
153152
common::Indirection<parser::OpenMPLoopConstruct>>>(
154-
loops.top()->t)
153+
loops.back()->t)
155154
.value()
156155
.value()));
157156
nextIt = block.erase(nextIt);
@@ -161,17 +160,17 @@ class CanonicalizationOfOmp {
161160

162161
if (auto *doCons{GetConstructIf<parser::DoConstruct>(*nextIt)}) {
163162
if (doCons->GetLoopControl()) {
164-
std::get<std::optional<parser::DoConstruct>>(loops.top()->t) =
163+
std::get<std::optional<parser::DoConstruct>>(loops.back()->t) =
165164
std::move(*doCons);
166165
nextIt = block.erase(nextIt);
167166
// try to match OmpEndLoopDirective
168167
while (nextIt != block.end() && !loops.empty()) {
169168
if (auto *endDir{
170169
GetConstructIf<parser::OmpEndLoopDirective>(*nextIt)}) {
171170
std::get<std::optional<parser::OmpEndLoopDirective>>(
172-
loops.top()->t) = std::move(*endDir);
171+
loops.back()->t) = std::move(*endDir);
173172
nextIt = block.erase(nextIt);
174-
loops.pop();
173+
loops.pop_back();
175174
} else {
176175
// If there is a mismatch bail out.
177176
break;

0 commit comments

Comments
 (0)