If location info is attached with an instruction then keep track of alloca slots...
[oota-llvm.git] / lib / CodeGen / SelectionDAG / FastISel.cpp
index 54544a4d1499eebf13fc44e4428f42f54909a196..0bec2cf9b1f934d572a390bdad1626e239289277 100644 (file)
@@ -407,7 +407,6 @@ bool FastISel::SelectCall(User *I) {
         || !DW->ShouldEmitDwarfDebug())
       return true;
 
-    Value *Variable = DI->getVariable();
     Value *Address = DI->getAddress();
     if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
       Address = BCI->getOperand(0);
@@ -418,8 +417,15 @@ bool FastISel::SelectCall(User *I) {
       StaticAllocaMap.find(AI);
     if (SI == StaticAllocaMap.end()) break; // VLAs.
     int FI = SI->second;
-    
-    DW->RecordVariable(cast<MDNode>(Variable), FI);
+    if (MMI) {
+      MetadataContext &TheMetadata = AI->getContext().getMetadata();
+      unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+      MDNode *AllocaLocation =
+        dyn_cast_or_null<MDNode>(TheMetadata.getMD(MDDbgKind, AI));
+      if (AllocaLocation)
+        MMI->setVariableDbgInfo(DI->getVariable(), AllocaLocation, FI);
+    }
+    DW->RecordVariable(DI->getVariable(), FI);
     return true;
   }
   case Intrinsic::eh_exception: {