[flang-commits] [flang] 58753de - [flang][OpenMP] Fix warning due to uninitialized pointer dereference during atomic update lowering

Nimish Mishra via flang-commits flang-commits at lists.llvm.org
Fri Jul 15 23:52:41 PDT 2022


Author: Nimish Mishra
Date: 2022-07-16T12:23:37+05:30
New Revision: 58753dea15c8ff72034e3e4a13b3a945aa295366

URL: https://github.com/llvm/llvm-project/commit/58753dea15c8ff72034e3e4a13b3a945aa295366
DIFF: https://github.com/llvm/llvm-project/commit/58753dea15c8ff72034e3e4a13b3a945aa295366.diff

LOG: [flang][OpenMP] Fix warning due to uninitialized pointer dereference during atomic update lowering

Reviewed By: kiranchandramohan, kazu

Differential Revision: https://reviews.llvm.org/D129914

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index f2efac35b908b..94029ac9e6b62 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -1127,14 +1127,6 @@ static void genOmpAtomicUpdateStatement(
 
   mlir::Value address = fir::getBase(converter.genExprAddr(
       *Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
-  const Fortran::semantics::Symbol *updateSymbol;
-  if (auto varDesignator = std::get_if<
-          Fortran::common::Indirection<Fortran::parser::Designator>>(
-          &assignmentStmtVariable.u)) {
-    if (const auto *name = getDesignatorNameIfDataRef(varDesignator->value())) {
-      updateSymbol = name->symbol;
-    }
-  }
   // If no hint clause is specified, the effect is as if
   // hint(omp_sync_hint_none) had been specified.
   mlir::IntegerAttr hint = nullptr;
@@ -1161,7 +1153,15 @@ static void genOmpAtomicUpdateStatement(
   firOpBuilder.createBlock(&atomicUpdateOp.getRegion(), {}, varTys, locs);
   mlir::Value val =
       fir::getBase(atomicUpdateOp.getRegion().front().getArgument(0));
-  converter.bindSymbol(*updateSymbol, val);
+  auto varDesignator =
+      std::get_if<Fortran::common::Indirection<Fortran::parser::Designator>>(
+          &assignmentStmtVariable.u);
+  assert(varDesignator && "Variable designator for atomic update assignment "
+                          "statement does not exist");
+  const auto *name = getDesignatorNameIfDataRef(varDesignator->value());
+  assert(name && name->symbol &&
+         "No symbol attached to atomic update variable");
+  converter.bindSymbol(*name->symbol, val);
   // Set the insert for the terminator operation to go at the end of the
   // block.
   mlir::Block &block = atomicUpdateOp.getRegion().back();


        


More information about the flang-commits mailing list