[PATCH] D107579: [Attributor]Fix PR51249: Stores from memory intrinsics incorrectly being replaced by undef

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 09:26:43 PDT 2021


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, ye-luo, ggeorgakoudis.
Herald added subscribers: ormris, okura, kuter, uenoku, hiraditya.
Herald added a reviewer: uenoku.
Herald added a reviewer: homerdin.
jhuber6 requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added subscribers: llvm-commits, bbn, sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: LLVM.

This patch fixes a bug observed in OpenMP reductions that occured when the
Attributor would attempt to simplify loads. The attributor would incorrectly
think that the memory intrinsic did not write to memory, and would then replace
the associated load with `undef` which would be turned to `NaN` in the final
output. This behaviour is observed in https://godbolt.org/z/j531848dv on line

314. This patch fixes https://bugs.llvm.org/show_bug.cgi?id=48607.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107579

Files:
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp


Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1344,8 +1344,8 @@
         handleAccess(A, *MI, Ptr, nullptr, AccessKind::AK_WRITE, 0, Changed,
                      nullptr, LengthVal);
       } else if (ArgNo == 1) {
-        handleAccess(A, *MI, Ptr, nullptr, AccessKind::AK_READ, 0, Changed,
-                     nullptr, LengthVal);
+        handleAccess(A, *MI, Ptr, nullptr, AccessKind::AK_READ_WRITE, 0,
+                     Changed, nullptr, LengthVal);
       } else {
         LLVM_DEBUG(dbgs() << "[AAPointerInfo] Unhandled memory intrinsic "
                           << *MI << "\n");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107579.364507.patch
Type: text/x-patch
Size: 787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/c39e0c27/attachment.bin>


More information about the llvm-commits mailing list