[PATCH] D130418: [LoopDataPrefetch] Fix crash when TTI doesn't set CacheLineSize

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 23 04:12:19 PDT 2022


Allen created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Allen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix https://github.com/llvm/llvm-project/issues/56681


https://reviews.llvm.org/D130418

Files:
  llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp


Index: llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
+++ llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
@@ -213,10 +213,9 @@
 bool LoopDataPrefetch::run() {
   // If PrefetchDistance is not set, don't run the pass.  This gives an
   // opportunity for targets to run this pass for selected subtargets only
-  // (whose TTI sets PrefetchDistance).
-  if (getPrefetchDistance() == 0)
+  // (whose TTI sets PrefetchDistance and CacheLineSize).
+  if (getPrefetchDistance() == 0 || TTI->getCacheLineSize() == 0)
     return false;
-  assert(TTI->getCacheLineSize() && "Cache line size is not set for target");
 
   bool MadeChange = false;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130418.447054.patch
Type: text/x-patch
Size: 761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220723/94e2d5dd/attachment.bin>


More information about the llvm-commits mailing list