[polly] 4cb7170 - [polly] Add nullptr check to fix #113772 (#114206)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 22:45:28 PDT 2024
Author: Karthika Devi C
Date: 2024-11-01T11:15:24+05:30
New Revision: 4cb71701994e129c1beca77134b39137ea8752c3
URL: https://github.com/llvm/llvm-project/commit/4cb71701994e129c1beca77134b39137ea8752c3
DIFF: https://github.com/llvm/llvm-project/commit/4cb71701994e129c1beca77134b39137ea8752c3.diff
LOG: [polly] Add nullptr check to fix #113772 (#114206)
The patch adds a nullptr check before accessing the loop blocks in
'hasPossiblyDistributableLoop' function. The existing check for the
loop’s containment in the region does not capture nullptr cases when the
region covers the entire function. Therefore, it’s better to exit if the
basic block isn’t part of any loop
Fixes #113772.
Added:
polly/test/ScopDetect/detect-full-functions.ll
Modified:
polly/lib/Analysis/ScopDetection.cpp
Removed:
################################################################################
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 79db3965de023e..73c26578005c35 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1698,6 +1698,8 @@ bool ScopDetection::hasPossiblyDistributableLoop(
DetectionContext &Context) const {
for (auto *BB : Context.CurRegion.blocks()) {
auto *L = LI.getLoopFor(BB);
+ if (!L)
+ continue;
if (!Context.CurRegion.contains(L))
continue;
if (Context.BoxedLoopsSet.count(L))
diff --git a/polly/test/ScopDetect/detect-full-functions.ll b/polly/test/ScopDetect/detect-full-functions.ll
new file mode 100644
index 00000000000000..178ef32827cab8
--- /dev/null
+++ b/polly/test/ScopDetect/detect-full-functions.ll
@@ -0,0 +1,17 @@
+; RUN: opt %loadNPMPolly '-passes=print<polly-detect>' -polly-process-unprofitable=false -disable-output -polly-detect-full-functions < %s 2>&1 | FileCheck %s
+
+; Verify if a simple function with basic block not part of loop doesn't crash with polly-process-unprofitable=false and polly-detect-full-functions flags.
+
+; CHECK: Detected Scops in Function foo
+
+define void @foo() {
+ br label %1
+
+1: ; preds = %1, %0
+ br i1 false, label %2, label %1
+
+2: ; preds = %1
+ %3 = load ptr, ptr null, align 8
+ store ptr null, ptr null, align 8
+ ret void
+}
More information about the llvm-commits
mailing list