Skip to content

Commit 58753de

Browse files
committed
[flang][OpenMP] Fix warning due to uninitialized pointer dereference during atomic update lowering
Reviewed By: kiranchandramohan, kazu Differential Revision: https://reviews.llvm.org/D129914
1 parent 1d6a904 commit 58753de

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

flang/lib/Lower/OpenMP.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,14 +1127,6 @@ static void genOmpAtomicUpdateStatement(
11271127

11281128
mlir::Value address = fir::getBase(converter.genExprAddr(
11291129
*Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
1130-
const Fortran::semantics::Symbol *updateSymbol;
1131-
if (auto varDesignator = std::get_if<
1132-
Fortran::common::Indirection<Fortran::parser::Designator>>(
1133-
&assignmentStmtVariable.u)) {
1134-
if (const auto *name = getDesignatorNameIfDataRef(varDesignator->value())) {
1135-
updateSymbol = name->symbol;
1136-
}
1137-
}
11381130
// If no hint clause is specified, the effect is as if
11391131
// hint(omp_sync_hint_none) had been specified.
11401132
mlir::IntegerAttr hint = nullptr;
@@ -1161,7 +1153,15 @@ static void genOmpAtomicUpdateStatement(
11611153
firOpBuilder.createBlock(&atomicUpdateOp.getRegion(), {}, varTys, locs);
11621154
mlir::Value val =
11631155
fir::getBase(atomicUpdateOp.getRegion().front().getArgument(0));
1164-
converter.bindSymbol(*updateSymbol, val);
1156+
auto varDesignator =
1157+
std::get_if<Fortran::common::Indirection<Fortran::parser::Designator>>(
1158+
&assignmentStmtVariable.u);
1159+
assert(varDesignator && "Variable designator for atomic update assignment "
1160+
"statement does not exist");
1161+
const auto *name = getDesignatorNameIfDataRef(varDesignator->value());
1162+
assert(name && name->symbol &&
1163+
"No symbol attached to atomic update variable");
1164+
converter.bindSymbol(*name->symbol, val);
11651165
// Set the insert for the terminator operation to go at the end of the
11661166
// block.
11671167
mlir::Block &block = atomicUpdateOp.getRegion().back();

0 commit comments

Comments
 (0)