[PATCH] D91833: [SelectionDAG] Avoid aliasing analysis if the object size is unknown.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 17:22:10 PST 2020


HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, niravd, courbet.
Herald added subscribers: ecnelises, hiraditya.
Herald added a project: LLVM.
HsiangKai requested review of this revision.

If the size of memory access is unknown, do not use it to analysis. One example of unknown size memory access is to load/store scalable vector objects on the stack.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91833

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/CodeGen/SelectionDAGAddressAnalysis.h"
 #include "llvm/CodeGen/ISDOpcodes.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
@@ -96,6 +97,12 @@
   int64_t PtrDiff;
   if (NumBytes0.hasValue() && NumBytes1.hasValue() &&
       BasePtr0.equalBaseIndex(BasePtr1, DAG, PtrDiff)) {
+    // If the size of memory access is unknown, do not use it to analysis.
+    // One example of unknown size memory access is to load/store scalable
+    // vector objects on the stack.
+    if (*NumBytes0 == static_cast<int64_t>(MemoryLocation::UnknownSize) ||
+        *NumBytes1 == static_cast<int64_t>(MemoryLocation::UnknownSize))
+      return false;
     // BasePtr1 is PtrDiff away from BasePtr0. They alias if none of the
     // following situations arise:
     IsAlias = !(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91833.306564.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201120/f21fc4b6/attachment.bin>


More information about the llvm-commits mailing list