summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorAmy Huang <akhuang@google.com>2019-06-20 17:15:21 +0000
committerAmy Huang <akhuang@google.com>2019-06-20 17:15:21 +0000
commit7fac5c8d940c91e1e7b8b704186b4649170b029f (patch)
treebf0d0c3cbafe46a0b6ddfa6873fbc6349d275dcb /clang/lib/CodeGen/CGDecl.cpp
parent01511192b23f531b8d378fa522d46647ce7b41a7 (diff)
downloadbcm5719-llvm-7fac5c8d940c91e1e7b8b704186b4649170b029f.tar.gz
bcm5719-llvm-7fac5c8d940c91e1e7b8b704186b4649170b029f.zip
Store a pointer to the return value in a static alloca and let the debugger use that
as the variable address for NRVO variables. Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63361 llvm-svn: 363952
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 233212c76be..c4e0d89c83c 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1403,12 +1403,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
getLangOpts().OpenMP
? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
: Address::invalid();
+ bool NRVO = getLangOpts().ElideConstructors && D.isNRVOVariable();
+
if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
address = OpenMPLocalAddr;
} else if (Ty->isConstantSizeType()) {
- bool NRVO = getLangOpts().ElideConstructors &&
- D.isNRVOVariable();
-
// If this value is an array or struct with a statically determinable
// constant initializer, there are optimizations we can do.
//
@@ -1561,8 +1560,16 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
// Emit debug info for local var declaration.
if (EmitDebugInfo && HaveInsertPoint()) {
+ Address DebugAddr = address;
+ bool UsePointerValue = NRVO && ReturnValuePointer.isValid();
DI->setLocation(D.getLocation());
- (void)DI->EmitDeclareOfAutoVariable(&D, address.getPointer(), Builder);
+
+ // If NRVO, use a pointer to the return address.
+ if (UsePointerValue)
+ DebugAddr = ReturnValuePointer;
+
+ (void)DI->EmitDeclareOfAutoVariable(&D, DebugAddr.getPointer(), Builder,
+ UsePointerValue);
}
if (D.hasAttr<AnnotateAttr>() && HaveInsertPoint())
OpenPOWER on IntegriCloud