[llvm] [ReachingDefAnalysis] Extend the analysis to stack objects. (PR #118097)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 11 07:44:49 PST 2025


================
@@ -209,19 +235,62 @@ void ReachingDefAnalysis::processBasicBlock(
   leaveBasicBlock(MBB);
 }
 
+void ReachingDefAnalysis::printAllReachingDefs(MachineFunction &MF) {
+  dbgs() << "RDA results for " << MF.getName() << "\n";
+  int Num = 0;
+  DenseMap<MachineInstr *, int> InstToNumMap;
+  SmallPtrSet<MachineInstr *, 2> Defs;
+  for (MachineBasicBlock &MBB : MF) {
+    for (MachineInstr &MI : MBB) {
+      for (MachineOperand &MO : MI.operands()) {
+        Register Reg;
+        if (MO.isFI()) {
+          int FrameIndex = MO.getIndex();
----------------
mgudim wrote:

It is possible. These are "FixedStackObjects". I inserted an assert for now.

In principal there is nothing special about fixed frame objects, the conversion FrameIndex->Reg is only needed so that we could use the same APIs for both stack slots and registers. One solution would be to have a parallel set of APIs for stack slots.

Another possibility is to finish MCRegister/Register conversion that you mentioned and also make sure register can represent stack slots including fixed objects. This looks like a rather big project by itself. 

So, for now, can we just have an assert?

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


More information about the llvm-commits mailing list