[flang-commits] [flang] fbb11b4 - [OpenMP][Flang] Fix OOB access for derived type mapping (#140948)

via flang-commits flang-commits at lists.llvm.org
Wed May 21 17:34:44 PDT 2025


Author: Akash Banerjee
Date: 2025-05-22T01:34:40+01:00
New Revision: fbb11b4c4e97c05623cfa624fe4c423587685cf3

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

LOG: [OpenMP][Flang] Fix OOB access for derived type mapping (#140948)

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP/Utils.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 173dceb07b193..711d4af287691 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -362,16 +362,18 @@ mlir::Value createParentSymAndGenIntermediateMaps(
           clauseLocation, firOpBuilder.getRefType(memberTy), curValue,
           llvm::SmallVector<fir::IntOrValue, 1>{idxConst});
 
-      // Skip mapping and the subsequent load if we're the final member or not
-      // a type with a descriptor such as a pointer/allocatable. If we're a
-      // final member, the map will be generated by the processMap call that
-      // invoked this function, and if we're not a type with a descriptor then
-      // we have no need of generating an intermediate map for it, as we only
-      // need to generate a map if a member is a descriptor type (and thus
-      // obscures the members it contains via a pointer in which it's data needs
-      // mapped)
-      if ((currentIndicesIdx == indices.size() - 1) ||
-          !fir::isTypeWithDescriptor(memberTy)) {
+      // If we're a final member, the map will be generated by the processMap
+      // call that invoked this function.
+      if (currentIndicesIdx == indices.size() - 1)
+        break;
+
+      // Skip mapping and the subsequent load if we're not
+      // a type with a descriptor such as a pointer/allocatable. If we're not a
+      // type with a descriptor then we have no need of generating an
+      // intermediate map for it, as we only need to generate a map if a member
+      // is a descriptor type (and thus obscures the members it contains via a
+      // pointer in which it's data needs mapped).
+      if (!fir::isTypeWithDescriptor(memberTy)) {
         currentIndicesIdx++;
         continue;
       }


        


More information about the flang-commits mailing list