Add getFrameIndexReference() to TargetRegisterInfo, which allows targets to
authorJim Grosbach <grosbach@apple.com>
Sun, 22 Nov 2009 20:14:00 +0000 (20:14 +0000)
committerJim Grosbach <grosbach@apple.com>
Sun, 22 Nov 2009 20:14:00 +0000 (20:14 +0000)
tell debug info which base register to use to reference a frame index on a
per-index basis. This is useful, for example, in the presence of dynamic
stack realignment when local variables are indexed via the stack pointer and
stack-based arguments via the frame pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89620 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetRegisterInfo.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 07737590af43b183bd533db9bfb0308b39de2d60..cb29c7306eaef80d4c115caf055dc2433e4ab633 100644 (file)
@@ -698,6 +698,18 @@ public:
   /// the stack frame of the specified index.
   virtual int getFrameIndexOffset(MachineFunction &MF, int FI) const;
 
+  /// getFrameIndexReference - This method should return the base register
+  /// and offset used to reference a frame index location. The offset is
+  /// returned directly, and the base register is returned via FrameReg.
+  virtual int getFrameIndexReference(MachineFunction &MF, int FI,
+                                     unsigned &FrameReg) const {
+    // By default, assume all frame indices are referenced via whatever
+    // getFrameRegister() says. The target can override this if it's doing
+    // something different.
+    FrameReg = getFrameRegister(MF);
+    return getFrameIndexOffset(MF, FI);
+  }
+
   /// getRARegister - This method should return the register where the return
   /// address can be found.
   virtual unsigned getRARegister() const = 0;
index 8d4783be8d3ed8f748b7267b3176a12c7c4d1608..1241c5ffeb3cfee386e8c3e6a70cb84733b991b6 100644 (file)
@@ -1182,8 +1182,9 @@ DIE *DwarfDebug::createDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit) {
   // Variables for abstract instances of inlined functions don't get a
   // location.
   MachineLocation Location;
-  Location.set(RI->getFrameRegister(*MF),
-               RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
+  unsigned FrameReg;
+  int Offset = RI->getFrameIndexReference(*MF, DV->getFrameIndex(), FrameReg);
+  Location.set(FrameReg, Offset);
 
 
   if (VD.hasComplexAddress())
@@ -1465,9 +1466,9 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV,
   // Add variable address.
   if (!Scope->isAbstractScope()) {
     MachineLocation Location;
-    Location.set(RI->getFrameRegister(*MF),
-                 RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
-
+    unsigned FrameReg;
+    int Offset = RI->getFrameIndexReference(*MF, DV->getFrameIndex(), FrameReg);
+    Location.set(FrameReg, Offset);
 
     if (VD.hasComplexAddress())
       addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);