@@ -1447,6 +1447,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
1447
1447
1448
1448
if (getLangOpts ().OpenMP && OpenMPLocalAddr.isValid ()) {
1449
1449
address = OpenMPLocalAddr;
1450
+ AllocaAddr = OpenMPLocalAddr;
1450
1451
} else if (Ty->isConstantSizeType ()) {
1451
1452
// If this value is an array or struct with a statically determinable
1452
1453
// constant initializer, there are optimizations we can do.
@@ -1492,6 +1493,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
1492
1493
// return slot, so that we can elide the copy when returning this
1493
1494
// variable (C++0x [class.copy]p34).
1494
1495
address = ReturnValue;
1496
+ AllocaAddr = ReturnValue;
1495
1497
1496
1498
if (const RecordType *RecordTy = Ty->getAs <RecordType>()) {
1497
1499
const auto *RD = RecordTy->getDecl ();
@@ -1503,7 +1505,8 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
1503
1505
// applied.
1504
1506
llvm::Value *Zero = Builder.getFalse ();
1505
1507
Address NRVOFlag =
1506
- CreateTempAlloca (Zero->getType (), CharUnits::One (), " nrvo" );
1508
+ CreateTempAlloca (Zero->getType (), CharUnits::One (), " nrvo" ,
1509
+ /* ArraySize=*/ nullptr , &AllocaAddr);
1507
1510
EnsureInsertPoint ();
1508
1511
Builder.CreateStore (Zero, NRVOFlag);
1509
1512
@@ -1605,10 +1608,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
1605
1608
DI->setLocation (D.getLocation ());
1606
1609
1607
1610
// If NRVO, use a pointer to the return address.
1608
- if (UsePointerValue)
1611
+ if (UsePointerValue) {
1609
1612
DebugAddr = ReturnValuePointer;
1610
-
1611
- (void )DI->EmitDeclareOfAutoVariable (&D, DebugAddr.getPointer (), Builder,
1613
+ AllocaAddr = ReturnValuePointer;
1614
+ }
1615
+ (void )DI->EmitDeclareOfAutoVariable (&D, AllocaAddr.getPointer (), Builder,
1612
1616
UsePointerValue);
1613
1617
}
1614
1618
@@ -2450,6 +2454,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
2450
2454
}
2451
2455
2452
2456
Address DeclPtr = Address::invalid ();
2457
+ Address AllocaPtr = Address::invalid ();
2453
2458
bool DoStore = false ;
2454
2459
bool IsScalar = hasScalarEvaluationKind (Ty);
2455
2460
// If we already have a pointer to the argument, reuse the input pointer.
@@ -2464,6 +2469,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
2464
2469
// from the default address space.
2465
2470
auto AllocaAS = CGM.getASTAllocaAddressSpace ();
2466
2471
auto *V = DeclPtr.getPointer ();
2472
+ AllocaPtr = DeclPtr;
2467
2473
auto SrcLangAS = getLangOpts ().OpenCL ? LangAS::opencl_private : AllocaAS;
2468
2474
auto DestLangAS =
2469
2475
getLangOpts ().OpenCL ? LangAS::opencl_private : LangAS::Default;
@@ -2500,10 +2506,11 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
2500
2506
: Address::invalid ();
2501
2507
if (getLangOpts ().OpenMP && OpenMPLocalAddr.isValid ()) {
2502
2508
DeclPtr = OpenMPLocalAddr;
2509
+ AllocaPtr = DeclPtr;
2503
2510
} else {
2504
2511
// Otherwise, create a temporary to hold the value.
2505
2512
DeclPtr = CreateMemTemp (Ty, getContext ().getDeclAlign (&D),
2506
- D.getName () + " .addr" );
2513
+ D.getName () + " .addr" , &AllocaPtr );
2507
2514
}
2508
2515
DoStore = true ;
2509
2516
}
@@ -2579,7 +2586,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
2579
2586
if (CGDebugInfo *DI = getDebugInfo ()) {
2580
2587
if (CGM.getCodeGenOpts ().hasReducedDebugInfo () && !CurFuncIsThunk) {
2581
2588
llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariable (
2582
- &D, DeclPtr .getPointer (), ArgNo, Builder);
2589
+ &D, AllocaPtr .getPointer (), ArgNo, Builder);
2583
2590
if (const auto *Var = dyn_cast_or_null<ParmVarDecl>(&D))
2584
2591
DI->getParamDbgMappings ().insert ({Var, DILocalVar});
2585
2592
}
0 commit comments