[clang-tools-extra] Clean up strange uses of getAnalysisIfAvailable (PR #65729)

Björn Pettersson via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 11 02:08:10 PDT 2023


================
@@ -3280,7 +3280,7 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
     if (skipFunction(F))
       return false;
 
-    auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
+    auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
----------------
bjope wrote:

IIUC GVN doesn't depend on LoopInfo itself. It should just make sure to preserve it if it is available. So one might wonder if it is the addRequire that should be questioned and possibly removed instead.
But it's been like this for years (that it is required), and messing around with the legacy PM analysis dependencies for an IR pass (even if it is used by some backends) is perhaps not worth it.

Therefore I think you proposed change is ok. Or you could just leave this as is, since the IfAvailable part in some sense indicate that the pass itself doesn't depend on the analysis.

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


More information about the cfe-commits mailing list