Skip to content

Commit 6ddacf5

Browse files
committed
Use llvm::SmallVector instead of std::stack
1 parent 6056202 commit 6ddacf5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

flang/lib/Semantics/canonicalize-omp.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "flang/Parser/parse-tree-visitor.h"
1111
#include "flang/Parser/parse-tree.h"
1212
#include "flang/Semantics/semantics.h"
13-
14-
#include <stack>
1513
// After Loop Canonicalization, rewrite OpenMP parse tree to make OpenMP
1614
// Constructs more structured which provide explicit scopes for later
1715
// structural checks and semantic analysis.
@@ -150,8 +148,8 @@ class CanonicalizationOfOmp {
150148
if (GetConstructIf<parser::CompilerDirective>(*nextIt))
151149
continue;
152150
// Keep track of the loops to handle the end loop directives
153-
std::stack<parser::OpenMPLoopConstruct *> loops;
154-
loops.push(&x);
151+
llvm::SmallVector<parser::OpenMPLoopConstruct *> loops;
152+
loops.push_back(&x);
155153
if (auto *innerConstruct{
156154
GetConstructIf<parser::OpenMPConstruct>(*nextIt)}) {
157155
if (auto *innerOmpLoop{
@@ -162,12 +160,12 @@ class CanonicalizationOfOmp {
162160
if (innerDir.v == llvm::omp::Directive::OMPD_tile) {
163161
std::get<std::optional<
164162
common::Indirection<parser::OpenMPLoopConstruct>>>(
165-
loops.top()->t) = std::move(*innerOmpLoop);
163+
loops.back()->t) = std::move(*innerOmpLoop);
166164
// Retrieveing the address so that DoConstruct or inner loop can be
167165
// set later.
168-
loops.push(&(std::get<std::optional<
166+
loops.push_back(&(std::get<std::optional<
169167
common::Indirection<parser::OpenMPLoopConstruct>>>(
170-
loops.top()->t)
168+
loops.back()->t)
171169
.value()
172170
.value()));
173171
nextIt = block.erase(nextIt);
@@ -180,16 +178,16 @@ class CanonicalizationOfOmp {
180178
// move DoConstruct
181179
std::get<std::optional<std::variant<parser::DoConstruct,
182180
common::Indirection<parser::OpenMPLoopConstruct>>>>(
183-
loops.top()->t) = std::move(*doCons);
181+
loops.back()->t) = std::move(*doCons);
184182
nextIt = block.erase(nextIt);
185183
// try to match OmpEndLoopDirective
186184
while (nextIt != block.end() && !loops.empty()) {
187185
if (auto *endDir{
188186
GetConstructIf<parser::OmpEndLoopDirective>(*nextIt)}) {
189187
std::get<std::optional<parser::OmpEndLoopDirective>>(
190-
loops.top()->t) = std::move(*endDir);
188+
loops.back()->t) = std::move(*endDir);
191189
nextIt = block.erase(nextIt);
192-
loops.pop();
190+
loops.pop_back();
193191
} else {
194192
// If there is a mismatch bail out.
195193
break;

0 commit comments

Comments
 (0)