[polly] [Polly] Use GenDT in assertion (PR #179433)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 03:02:57 PST 2026


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/179433

`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`.

Fixes: #179135

>From 3b184779bd5e8bc1f00c5f1d42fe8dad23f6d75c Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 3 Feb 2026 11:55:00 +0100
Subject: [PATCH] [Polly] Fix #179135

---
 polly/lib/CodeGen/BlockGenerators.cpp    |  8 +++---
 polly/test/CodeGen/OpenMP/issue179135.ll | 32 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100644 polly/test/CodeGen/OpenMP/issue179135.ll

diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index b87c40c94243e..9d3e2bfea8713 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -778,12 +778,12 @@ void BlockGenerator::generateScalarStores(
 
           Val = getNewValue(Stmt, Val, BBMap, LTS, L);
           assert((!isa<Instruction>(Val) ||
-                  DT.dominates(cast<Instruction>(Val)->getParent(),
-                               Builder.GetInsertBlock())) &&
+                  GenDT->dominates(cast<Instruction>(Val)->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(Val, Address);
diff --git a/polly/test/CodeGen/OpenMP/issue179135.ll b/polly/test/CodeGen/OpenMP/issue179135.ll
new file mode 100644
index 0000000000000..77bb86dde23df
--- /dev/null
+++ b/polly/test/CodeGen/OpenMP/issue179135.ll
@@ -0,0 +1,32 @@
+; RUN: opt  %loadNPMPolly '--passes=polly-custom<delicm;codegen>' --polly-parallel -S < %s | FileCheck %s
+
+; https://github.com/llvm/llvm-project/issues/179135
+; 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(ptr %arg, i32 %arg1) {
+bb:
+  br label %bb2
+
+bb2:                                              ; preds = %bb9, %bb
+  %i = phi i64 [ 0, %bb ], [ %i10, %bb9 ]
+  br label %bb3
+
+bb3:                                              ; preds = %bb3, %bb2
+  %i4 = phi i64 [ 0, %bb2 ], [ %i7, %bb3 ]
+  %i5 = phi i32 [ 0, %bb2 ], [ %arg1, %bb3 ]
+  %i6 = getelementptr i32, ptr %arg, i64 %i
+  store i32 %i5, ptr %i6, align 4
+  %i7 = add i64 %i4, 1
+  %i8 = icmp eq i64 %i4, 1
+  br i1 %i8, label %bb9, label %bb3
+
+bb9:                                              ; preds = %bb3
+  %i10 = add i64 %i, 1
+  %i11 = icmp eq i64 %i, 1
+  br i1 %i11, label %bb12, label %bb2
+
+bb12:                                             ; preds = %bb9
+  ret void
+}



More information about the llvm-commits mailing list