Dwarf requires variable entries to be in the source order. Right now, since we are recording variable information at isel time this means parameters would appear in the reverse order. The short term fix is to issue recordVariable() at asm printing time instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46724 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index f581bd6..820d75c 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -118,9 +118,8 @@
 
   SwitchToDataSection("");   // Reset back to no section.
   
-  if (MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>()) {
-    MMI->AnalyzeModule(M);
-  }
+  MMI = getAnalysisToUpdate<MachineModuleInfo>();
+  if (MMI) MMI->AnalyzeModule(M);
   
   return false;
 }
@@ -1291,8 +1290,12 @@
 
 /// printDeclare - This method prints a local variable declaration used by
 /// debug tables.
+/// FIXME: It doesn't really print anything rather it inserts a DebugVariable
+/// entry into dwarf table.
 void AsmPrinter::printDeclare(const MachineInstr *MI) const {
-  // Do nothing.
+  int FI = MI->getOperand(0).getIndex();
+  GlobalValue *GV = MI->getOperand(1).getGlobal();
+  MMI->RecordVariable(GV, FI);
 }
 
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM