From e0a94bfe9f36f5dc79a18e33fd03963fa4024158 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 14 May 2010 21:01:35 +0000 Subject: Add support to preserve type info for the variables that are removed by the optimizer. llvm-svn: 103798 --- llvm/lib/Analysis/DebugInfo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Analysis/DebugInfo.cpp') diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index 92f91f4d600..194811be903 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -1028,7 +1028,7 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, StringRef Name, DIFile F, unsigned LineNo, - DIType Ty) { + DIType Ty, bool OptimizedBuild) { Value *Elts[] = { GetTagConstant(Tag), Context, @@ -1037,7 +1037,12 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), Ty, }; - return DIVariable(MDNode::get(VMContext, &Elts[0], 6)); + MDNode *Node = MDNode::get(VMContext, &Elts[0], 6); + if (OptimizedBuild) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.lv"); + NMD->addOperand(Node); + } + return DIVariable(Node); } -- cgit v1.2.3