From 4dbca6dfd4d76d070c7d43337e74c8d532c5ac53 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 1 Oct 2009 01:03:26 +0000 Subject: If location info is attached with an instruction then keep track of alloca slots used by a variable. This info will be used by AsmPrinter to emit debug info for variables. llvm-svn: 83189 --- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG') diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 54544a4d149..0bec2cf9b1f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -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(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(Variable), FI); + if (MMI) { + MetadataContext &TheMetadata = AI->getContext().getMetadata(); + unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); + MDNode *AllocaLocation = + dyn_cast_or_null(TheMetadata.getMD(MDDbgKind, AI)); + if (AllocaLocation) + MMI->setVariableDbgInfo(DI->getVariable(), AllocaLocation, FI); + } + DW->RecordVariable(DI->getVariable(), FI); return true; } case Intrinsic::eh_exception: { -- cgit v1.2.3