aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Lower/Bridge.cpp
diff options
context:
space:
mode:
authorjeanPerier <jperier@nvidia.com>2023-10-17 09:11:53 +0200
committerGitHub <noreply@github.com>2023-10-17 09:11:53 +0200
commitbfcd05317d0fbe90474eda13a4dbf33c2cee4130 (patch)
tree346c401c7bf55851dec82b2a1ed66611ec931ae6 /flang/lib/Lower/Bridge.cpp
parent77ab08e1ffa875f0e739357b81cdb197ff19ecb0 (diff)
downloadllvm-bfcd05317d0fbe90474eda13a4dbf33c2cee4130.zip
llvm-bfcd05317d0fbe90474eda13a4dbf33c2cee4130.tar.gz
llvm-bfcd05317d0fbe90474eda13a4dbf33c2cee4130.tar.bz2
[flang][hlfir] Do not emit extra declare for dummy used in BLOCK (#69184)
When a variable is used in a specification expression in a scope, it is added to the list of variables that must be instantiated when lowering the scope. When lowering a BLOCK, this caused instantiateVar to be called again on all the host block variables appearing in block variable specification expressions. This caused an extra declare to be emitted for dummy inside block (for non dummy, instantiateVar is a no-op if the symbol is already mapped). Only call instantiateVar if the symbol is not mapped when lowering BLOCK variables.
Diffstat (limited to 'flang/lib/Lower/Bridge.cpp')
-rw-r--r--flang/lib/Lower/Bridge.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index ef8540c..f26a1aa 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -2610,8 +2610,12 @@ private:
scopeBlockIdMap.try_emplace(&scope, ++blockId);
Fortran::lower::AggregateStoreMap storeMap;
for (const Fortran::lower::pft::Variable &var :
- Fortran::lower::pft::getScopeVariableList(scope))
- instantiateVar(var, storeMap);
+ Fortran::lower::pft::getScopeVariableList(scope)) {
+ // Do no instantiate again variables from the block host
+ // that appears in specification of block variables.
+ if (!var.hasSymbol() || !lookupSymbol(var.getSymbol()))
+ instantiateVar(var, storeMap);
+ }
} else if (e.getIf<Fortran::parser::EndBlockStmt>()) {
if (eval.lowerAsUnstructured())
maybeStartBlock(e.block);