[flang-commits] [flang] [flang] Allow multiple identical DATA initializations (PR #177063)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 21 10:53:14 PST 2026


================
@@ -52,11 +53,17 @@ class InitialImage {
               x.values().size() * static_cast<std::size_t>(*elementBytes)) {
         return SizeMismatch;
       } else if (bytes == 0) {
-        return Ok;
+        return OkNoChange;
       } else {
         // TODO endianness
-        std::memcpy(&data_.at(offset), &x.values().at(0), bytes);
-        return Ok;
+        auto *to{&data_.at(offset)};
+        const auto *from{&x.values().at(0)};
+        if (std::memcmp(to, from, bytes) == 0) {
+          return OkNoChange;
+        } else {
+          std::memcpy(&data_.at(offset), &x.values().at(0), bytes);
+          return Ok;
+        }
----------------
tmjbios wrote:

Do we need to worry about a memcopy vs memmove here (overlapping data_ and x ranges)? I don't _think_ we do, but thought I'd ask.

https://github.com/llvm/llvm-project/pull/177063


More information about the flang-commits mailing list