Skip to content

Commit ffe01de

Browse files
committed
[polly] Skip instructions of different function in isHoistableLoad.
After patch 5ce47a5, some assert crashes occur in Polly. This issue arises because an instruction from one function queries the Dominator Tree (DT) of another function. To fix this, the `isHoistableLoad` function now skips instructions that belong to different function while iterating.
1 parent 2a4c74c commit ffe01de

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

polly/lib/Support/ScopHelper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ bool polly::isHoistableLoad(LoadInst *LInst, Region &R, LoopInfo &LI,
604604

605605
for (auto *User : Ptr->users()) {
606606
auto *UserI = dyn_cast<Instruction>(User);
607-
if (!UserI || !R.contains(UserI))
607+
if (!UserI || UserI->getFunction() != LInst->getFunction() ||
608+
!R.contains(UserI))
608609
continue;
609610
if (!UserI->mayWriteToMemory())
610611
continue;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: opt %loadNPMPolly '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
2+
3+
; CHECK: Detected Scops in Function foo
4+
5+
; This unit test case is to check if the following IR does not crash in isHoistableLoad function during Scop Detection.
6+
7+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
8+
target triple = "aarch64-unknown-linux-gnueabi"
9+
10+
define void @foo(ptr %block) {
11+
entry:
12+
br label %for.body
13+
14+
for.cond1.preheader: ; preds = %for.body
15+
%0 = load ptr, ptr null, align 8
16+
%1 = load i16, ptr %block, align 2
17+
%2 = load i16, ptr %0, align 2
18+
br label %foo.exit
19+
20+
for.body: ; preds = %for.body, %entry
21+
br i1 false, label %for.cond1.preheader, label %for.body
22+
23+
foo.exit: ; preds = %for.cond1.preheader
24+
ret void
25+
}
26+
27+
define void @init_foo() {
28+
entry:
29+
store ptr null, ptr null, align 8
30+
ret void
31+
}

0 commit comments

Comments
 (0)