[llvm] [Uniformity] Legacy PM: Set UniformityInfoWrapperPass isCFGOnly to false (PR #148165)
Jim M. R. Teichgräber via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 02:19:39 PDT 2025
https://github.com/J-MR-T created https://github.com/llvm/llvm-project/pull/148165
Currently, Uniformity Analysis is preserved in the Legacy PM when a pass sets `setPreservesCFG()`. This is incorrect: any values' uniformity not only depends on the CFG, but also on the uniformity of other values, so a CFG-preserving change in many cases doesn't preserve uniformity analysis.
This corrected behavior also matches the behavior of the new PM.
---
On its own, this change does not affect the pass pipeline because of the happenstance of pass ordering. In a minute, I'll also create a PR to change AMDGPULateCodeGenPrepare and link this here, this will have an actual impact on pass executions. That PR will also include changes to the `amdgpu/llc-pipeline.ll` test in order to check that this change works, but if this is preferred, I would also be happy to try to extend this PR to add an isolated test case; though my personal opinion is that the test in the other PR should suffice, as it should also accurately pinpoint failures related to this change.
---
I ran `git-clang-format` on my changes. I tested them using the `check-llvm` target; no unexpected failures occurred.
>From 90f1d0a881a21a8b4f192622d798c290770fda63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jim=20Teichgr=C3=A4ber?= <Jim.Teichgraber at amd.com>
Date: Fri, 11 Jul 2025 10:16:25 +0200
Subject: [PATCH] set legacy PM UniformityInfoWrapperPass isCFGOnly to false
---
llvm/lib/Analysis/UniformityAnalysis.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/UniformityAnalysis.cpp b/llvm/lib/Analysis/UniformityAnalysis.cpp
index 2101fdfacfc8f..0daf4041a72f3 100644
--- a/llvm/lib/Analysis/UniformityAnalysis.cpp
+++ b/llvm/lib/Analysis/UniformityAnalysis.cpp
@@ -150,8 +150,11 @@ INITIALIZE_PASS_BEGIN(UniformityInfoWrapperPass, "uniformity",
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(CycleInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
+// Though Uniformity Analysis depends on the CFG,
+// it also needs to be invalidated if values are changed, so isCFGOnly: false.
+// See NOTE on updatability at the start of GenericUniformityImpl.h
INITIALIZE_PASS_END(UniformityInfoWrapperPass, "uniformity",
- "Uniformity Analysis", true, true)
+ "Uniformity Analysis", false, true)
void UniformityInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
More information about the llvm-commits
mailing list