From: Daniel Dunbar Date: Wed, 30 Jun 2010 21:27:58 +0000 (+0000) Subject: IRgen: Fix debug info regression in r106970; when we eliminate the return value X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21fcc8f01246b91dbef65e7af85f2f0947758a00;p=clang IRgen: Fix debug info regression in r106970; when we eliminate the return value store make sure to move the debug metadata from the store (which is actual 'return' statement location) to the return instruction (which otherwise would have the function end location as its debug info). - Tested by gdb test suite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107322 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 24a64cfa44..29104424ac 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -975,7 +975,8 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI) { Builder.CreateRetVoid(); return; } - + + llvm::MDNode *RetDbgInfo = 0; llvm::Value *RV = 0; QualType RetTy = FI.getReturnType(); const ABIArgInfo &RetAI = FI.getReturnInfo(); @@ -1009,6 +1010,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI) { RV = Builder.CreateLoad(ReturnValue); } else { // Get the stored value and nuke the now-dead store. + RetDbgInfo = SI->getDbgMetadata(); RV = SI->getValueOperand(); SI->eraseFromParent(); @@ -1031,10 +1033,9 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI) { assert(0 && "Invalid ABI kind for return argument"); } - if (RV) - Builder.CreateRet(RV); - else - Builder.CreateRetVoid(); + llvm::Instruction *Ret = RV ? Builder.CreateRet(RV) : Builder.CreateRetVoid(); + if (RetDbgInfo) + Ret->setDbgMetadata(RetDbgInfo); } RValue CodeGenFunction::EmitDelegateCallArg(const VarDecl *Param) {