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

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 22:09:29 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd485c1b73e13: [LoopDataPrefetch] Fix crash when TTI doesn't set CacheLineSize (authored by Allen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130418

Files:
  llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
  llvm/test/Transforms/LoopDataPrefetch/AArch64/pr56681.ll


Index: llvm/test/Transforms/LoopDataPrefetch/AArch64/pr56681.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopDataPrefetch/AArch64/pr56681.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt --loop-data-prefetch --prefetch-distance=3000 -debug-only=loop-data-prefetch -S < %s 2>&1 | FileCheck %s
+
+; REQUIRES: asserts
+
+; CHECK:  Please set both PrefetchDistance and CacheLineSize for loop data prefetch
+
+define void @calc() {
+; CHECK-LABEL: @calc(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret void
+;
+entry:
+  ret void
+}
Index: llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
+++ llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
@@ -213,10 +213,12 @@
 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) {
+    LLVM_DEBUG(dbgs() << "Please set both PrefetchDistance and CacheLineSize "
+                         "for loop data prefetch.\n");
     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.447567.patch
Type: text/x-patch
Size: 1555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/43680c38/attachment.bin>


More information about the llvm-commits mailing list