| Issue |
204279
|
| Summary |
[polly] BasePtrOriginSAI is not considered while hoisting loads
|
| Labels |
|
| Assignees |
|
| Reporter |
rahulana-quic
|
Consider the following:
```
define fastcc void @foo(i32 %arg) {
bb:
br label %bb1
bb1:
%getelementptr = getelementptr i8, ptr null, i64 32
%load = load ptr, ptr %getelementptr, align 8
%load2 = load i32, ptr %load, align 4
%icmp = icmp ugt i32 %arg, 0
br i1 %icmp, label %bb3, label %bb4
bb3:
store ptr null, ptr null, align 8
br label %bb4
bb4:
ret void
}
```
>From polly-debug:
```
i32 MemRef_load[*]; [BasePtrOrigin: MemRef0]
MustWriteAccess := { Stmt_bb3[] -> MemRef0[0] : arg > 0 }
```
MemRef_load has BasePtrOriginSAI = MemRef0 and MemRef0 is written inside the scop making the load of MemRef_load not invariant across the scop. But the hoisting decision in getNonHoistableCtx approves the hoist.
If the write to MemRef0 changes the stored pointer (for example, a call in the scop reallocating the object whose address is stored there) any subsequent store through the hoisted derived address is to the stale memory location, producing runtime failures.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs