[flang-commits] [PATCH] D144134: [flang][runtime] MayAlias() must be false for Unallocated descriptors

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Feb 15 13:25:32 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74a5d7471fbd: [flang][runtime] MayAlias() must be false for unallocated descriptors (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144134/new/

https://reviews.llvm.org/D144134

Files:
  flang/runtime/assign.cpp


Index: flang/runtime/assign.cpp
===================================================================
--- flang/runtime/assign.cpp
+++ flang/runtime/assign.cpp
@@ -126,6 +126,11 @@
 // possibly overlap in memory?  Note that the descriptors themeselves
 // are included in the test.
 static bool MayAlias(const Descriptor &x, const Descriptor &y) {
+  const char *xBase{x.OffsetElement()};
+  const char *yBase{y.OffsetElement()};
+  if (!xBase || !yBase) {
+    return false; // not both allocated
+  }
   const char *xDesc{reinterpret_cast<const char *>(&x)};
   const char *xDescLast{xDesc + x.SizeInBytes()};
   const char *yDesc{reinterpret_cast<const char *>(&y)};
@@ -133,8 +138,6 @@
   std::int64_t xLeast, xMost, yLeast, yMost;
   MaximalByteOffsetRange(x, xLeast, xMost);
   MaximalByteOffsetRange(y, yLeast, yMost);
-  const char *xBase{x.OffsetElement()};
-  const char *yBase{y.OffsetElement()};
   if (RangesOverlap(xDesc, xDescLast, yBase + yLeast, yBase + yMost) ||
       RangesOverlap(yDesc, yDescLast, xBase + xLeast, xBase + xMost)) {
     // A descriptor overlaps with the storage described by the other;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144134.497778.patch
Type: text/x-patch
Size: 1123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230215/5d31d35e/attachment-0001.bin>


More information about the flang-commits mailing list