[llvm-commits] [llvm] r113843 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp

Devang Patel dpatel at apple.com
Tue Sep 14 13:29:31 PDT 2010


Author: dpatel
Date: Tue Sep 14 15:29:31 2010
New Revision: 113843

URL: http://llvm.org/viewvc/llvm-project?rev=113843&view=rev
Log:
Use frame index, if available for byval argument while lowering dbg_declare. Otherwise let getRegForValue() find register for this argument.


Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=113843&r1=113842&r2=113843&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Sep 14 15:29:31 2010
@@ -467,24 +467,28 @@
       return true;
 
     const Value *Address = DI->getAddress();
-    if (!Address)
+    if (!Address || isa<UndefValue>(Address) || isa<AllocaInst>(Address))
       return true;
-    if (isa<UndefValue>(Address))
-      return true;
-    const AllocaInst *AI = dyn_cast<AllocaInst>(Address);
-    // Don't handle byval struct arguments or VLAs, for example.
-    if (!AI) {
-      // Building the map above is target independent.  Generating DBG_VALUE
-      // inline is target dependent; do this now.
-      DenseMap<const Value *, unsigned>::iterator It =
-        FuncInfo.ValueMap.find(Address);
-      if (0 && It != FuncInfo.ValueMap.end()) {
-        BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, 
-                TII.get(TargetOpcode::DBG_VALUE))
-               .addReg(It->second, RegState::Debug).addImm(0).addMetadata(DI->getVariable());
-      } else
-        (void)TargetSelectInstruction(cast<Instruction>(I));
+
+    unsigned Reg = 0;
+    unsigned Offset = 0;
+    if (const Argument *Arg = dyn_cast<Argument>(Address)) {
+      if (Arg->hasByValAttr()) {
+        // Byval arguments' frame index is recorded during argument lowering.
+        // Use this info directly.
+        Offset = FuncInfo.getByValArgumentFrameIndex(Arg);
+        if (Offset)
+          Reg = TRI.getFrameRegister(*FuncInfo.MF);
+      } 
     }
+    if (!Reg)
+      Reg = getRegForValue(Address);
+    
+    if (Reg)
+      BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, 
+              TII.get(TargetOpcode::DBG_VALUE))
+        .addReg(Reg, RegState::Debug).addImm(Offset)
+        .addMetadata(DI->getVariable());
     return true;
   }
   case Intrinsic::dbg_value: {





More information about the llvm-commits mailing list