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
Builder.CreateRetVoid();
return;
}
-
+
+ llvm::MDNode *RetDbgInfo = 0;
llvm::Value *RV = 0;
QualType RetTy = FI.getReturnType();
const ABIArgInfo &RetAI = FI.getReturnInfo();
RV = Builder.CreateLoad(ReturnValue);
} else {
// Get the stored value and nuke the now-dead store.
+ RetDbgInfo = SI->getDbgMetadata();
RV = SI->getValueOperand();
SI->eraseFromParent();
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) {