[clang] 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:09 PDT 2023


================
@@ -935,7 +935,7 @@ bool AArch64ConditionalCompares::runOnMachineFunction(MachineFunction &MF) {
   SchedModel = MF.getSubtarget().getSchedModel();
   MRI = &MF.getRegInfo();
   DomTree = &getAnalysis<MachineDominatorTree>();
-  Loops = getAnalysisIfAvailable<MachineLoopInfo>();
+  Loops = &getAnalysis<MachineLoopInfo>();
----------------
bjope wrote:

I think there are some "weird" things going on here. But maybe not worth digging into those unless being an AArch64 maintainer.

Afaict the goal here is to make sure MachineLoopInfo is preserved. So this pass shouldn't really need to require it explicitly. However, the MachineTraceMetrics pass is also using MachineLoopInfo transitively. So, the MachineLoopInfo analysis will be run. Although I think there is a "bug" in MachineTraceMetrics related to not using addRequiredTransitive. So things might break if removing the addRequired in this pass.

To sum up. The proposed change is probably harmless and OK. Just saying that the analysis pass dependencies used in here seem to be a bit ad-hoc(?).

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


More information about the cfe-commits mailing list