[llvm] [Uniformity] Legacy PM: Set UniformityInfoWrapperPass isCFGOnly to false (PR #148165)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 02:20:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Jim M. R. Teichgräber (J-MR-T)

<details>
<summary>Changes</summary>

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.



---
Full diff: https://github.com/llvm/llvm-project/pull/148165.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/UniformityAnalysis.cpp (+4-1) 


``````````diff
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();

``````````

</details>


https://github.com/llvm/llvm-project/pull/148165


More information about the llvm-commits mailing list