[Polly] Use GenDT in assertion (#186164)

`DT` is always the analysis for the to-be-optimized function while
`GenDT` is the analysis of the function that we currently generate code
for, which can also be an outlined function. Here, we want to check
dominance in the generated code, hence we must use `GenDT`.

#179433 already fixed the same issue for `BlockGenerator`. The same
pattern is used in `RegionGenerator` which is fixed here. A good
argument to avoid code duplication.

Fixes: #185313

Thanks to @jaschiu for the bug report and reproducer
This commit is contained in:
Michael Kruse 2026-03-12 17:36:19 +01:00 committed by GitHub
parent 614b860af0
commit 42b4dce07c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 4 deletions

View File

@ -1319,12 +1319,12 @@ void RegionGenerator::generateScalarStores(
Value *Address = getImplicitAddress(*MA, getLoopForStmt(Stmt), LTS,
BBMap, NewAccesses);
assert((!isa<Instruction>(NewVal) ||
DT.dominates(cast<Instruction>(NewVal)->getParent(),
Builder.GetInsertBlock())) &&
GenDT->dominates(cast<Instruction>(NewVal)->getParent(),
Builder.GetInsertBlock())) &&
"Domination violation");
assert((!isa<Instruction>(Address) ||
DT.dominates(cast<Instruction>(Address)->getParent(),
Builder.GetInsertBlock())) &&
GenDT->dominates(cast<Instruction>(Address)->getParent(),
Builder.GetInsertBlock())) &&
"Domination violation");
Builder.CreateStore(NewVal, Address);
});

View File

@ -0,0 +1,28 @@
; RUN: opt %loadNPMPolly '-passes=polly-custom<delicm;codegen>' -polly-parallel --polly-parallel-force -S < %s | FileCheck %s
; https://github.com/llvm/llvm-project/issues/185313
; CHECK: @func_polly_subfn(
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
define void @func(i1 %arg) {
bb:
br label %bb1
bb1: ; preds = %bb2, %bb
%i = phi i16 [ 0, %bb ], [ %i5, %bb2 ]
%spec.select = select i1 %arg, i8 0, i8 0
br i1 %arg, label %bb2, label %bb2
bb2: ; preds = %bb1, %bb1
%i3 = zext i16 %i to i64
%i4 = getelementptr i8, ptr null, i64 %i3
store i8 %spec.select, ptr %i4, align 1
%i5 = add i16 %i, 1
%i6 = zext i16 %i to i32
%i7 = icmp ugt i32 1, %i6
br i1 %i7, label %bb1, label %bb8
bb8: ; preds = %bb2
ret void
}