[llvm] [Uniformity] Remove dependence on CycleInfo in old pass manager (PR #76011)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 19:26:51 PST 2023


================
@@ -152,26 +152,34 @@ UniformityInfoWrapperPass::UniformityInfoWrapperPass() : FunctionPass(ID) {
 INITIALIZE_PASS_BEGIN(UniformityInfoWrapperPass, "uniformity",
                       "Uniformity Analysis", true, true)
 INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(CycleInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
 INITIALIZE_PASS_END(UniformityInfoWrapperPass, "uniformity",
                     "Uniformity Analysis", true, true)
 
 void UniformityInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
   AU.addRequired<DominatorTreeWrapperPass>();
-  AU.addRequiredTransitive<CycleInfoWrapperPass>();
   AU.addRequired<TargetTransformInfoWrapperPass>();
 }
 
 bool UniformityInfoWrapperPass::runOnFunction(Function &F) {
-  auto &cycleInfo = getAnalysis<CycleInfoWrapperPass>().getResult();
   auto &domTree = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   auto &targetTransformInfo =
       getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
 
   m_function = &F;
-  m_uniformityInfo = UniformityInfo{domTree, cycleInfo, &targetTransformInfo};
+
+  // FIXME: CycleInfo is a transitive dependency for UniformityInfo, and we
+  // would have liked to say that CycleInfo is also preserved whenever
+  // UniformityInfo is preserved. But some passes like
+  // AMDGPUUnifyDivergentExitNodes do not update cycle membership and lists of
+  // cycle exits, since that facility is not available. The end result is that
+  // we cannot declare CycleInfo as a transitive depedency for UniformityInfo.
+  // Instead we recompute CycleInfo on demand. This is OK because it is rarely
+  // needed, and only affects the old pass manager.
+  m_cycleInfo.clear();
+  m_cycleInfo.compute(F);
+  m_uniformityInfo = UniformityInfo{domTree, m_cycleInfo, &targetTransformInfo};
----------------
ssahasra wrote:

I always find transitive dependencies in the old pass manager confusing. It is supposed to mean what you said, but the actual implementation is not clear to me.

Specifically for UniformityInfo, CycleInfo is used only during its computation and does not need to be present during the lifetime of the UniformityInfo itself. But then there is this implicit assumption in general, if UniformityInfo is updated, then CycleInfo may need to be present as a dependency. This is not true in this case because UnifyDivergentExitNodes doesn't actually update UniformityInfo in any way. If all this is implemented correctly, then CycleInfo does not need to be marked transitive ... it is not needed to be alive during the lifetime of UniformityInfo.

Actually @Pierre-vh, you had marked CycleInfo as a transitive dependency at some point; it must have fixed something for him. Do you remember what that was?

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


More information about the llvm-commits mailing list