8
8
9
9
#include " canonicalize-omp.h"
10
10
#include " flang/Parser/parse-tree-visitor.h"
11
- #include < stack>
12
11
// After Loop Canonicalization, rewrite OpenMP parse tree to make OpenMP
13
12
// Constructs more structured which provide explicit scopes for later
14
13
// structural checks and semantic analysis.
@@ -134,8 +133,8 @@ class CanonicalizationOfOmp {
134
133
if (GetConstructIf<parser::CompilerDirective>(*nextIt))
135
134
continue ;
136
135
// 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);
139
138
if (auto *innerConstruct{
140
139
GetConstructIf<parser::OpenMPConstruct>(*nextIt)}) {
141
140
if (auto *innerOmpLoop{
@@ -146,12 +145,12 @@ class CanonicalizationOfOmp {
146
145
if (innerDir.v == llvm::omp::Directive::OMPD_tile) {
147
146
std::get<std::optional<
148
147
common::Indirection<parser::OpenMPLoopConstruct>>>(
149
- loops.top ()->t ) = std::move (*innerOmpLoop);
148
+ loops.back ()->t ) = std::move (*innerOmpLoop);
150
149
// Retrieveing the address so that DoConstruct or inner loop can be
151
150
// set later.
152
- loops.push (&(std::get<std::optional<
151
+ loops.push_back (&(std::get<std::optional<
153
152
common::Indirection<parser::OpenMPLoopConstruct>>>(
154
- loops.top ()->t )
153
+ loops.back ()->t )
155
154
.value ()
156
155
.value ()));
157
156
nextIt = block.erase (nextIt);
@@ -161,17 +160,17 @@ class CanonicalizationOfOmp {
161
160
162
161
if (auto *doCons{GetConstructIf<parser::DoConstruct>(*nextIt)}) {
163
162
if (doCons->GetLoopControl ()) {
164
- std::get<std::optional<parser::DoConstruct>>(loops.top ()->t ) =
163
+ std::get<std::optional<parser::DoConstruct>>(loops.back ()->t ) =
165
164
std::move (*doCons);
166
165
nextIt = block.erase (nextIt);
167
166
// try to match OmpEndLoopDirective
168
167
while (nextIt != block.end () && !loops.empty ()) {
169
168
if (auto *endDir{
170
169
GetConstructIf<parser::OmpEndLoopDirective>(*nextIt)}) {
171
170
std::get<std::optional<parser::OmpEndLoopDirective>>(
172
- loops.top ()->t ) = std::move (*endDir);
171
+ loops.back ()->t ) = std::move (*endDir);
173
172
nextIt = block.erase (nextIt);
174
- loops.pop ();
173
+ loops.pop_back ();
175
174
} else {
176
175
// If there is a mismatch bail out.
177
176
break ;
0 commit comments