@@ -1494,16 +1494,16 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
1494
1494
1495
1495
// Collect virtual method info.
1496
1496
llvm::DIType *ContainingType = nullptr ;
1497
- unsigned Virtuality = 0 ;
1498
1497
unsigned VIndex = 0 ;
1499
1498
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1499
+ llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
1500
1500
int ThisAdjustment = 0 ;
1501
1501
1502
1502
if (Method->isVirtual ()) {
1503
1503
if (Method->isPure ())
1504
- Virtuality = llvm::dwarf::DW_VIRTUALITY_pure_virtual ;
1504
+ SPFlags | = llvm::DISubprogram::SPFlagPureVirtual ;
1505
1505
else
1506
- Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual ;
1506
+ SPFlags | = llvm::DISubprogram::SPFlagVirtual ;
1507
1507
1508
1508
if (CGM.getTarget ().getCXXABI ().isItaniumFamily ()) {
1509
1509
// It doesn't make sense to give a virtual destructor a vtable index,
@@ -1555,12 +1555,13 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
1555
1555
Flags |= llvm::DINode::FlagLValueReference;
1556
1556
if (Method->getRefQualifier () == RQ_RValue)
1557
1557
Flags |= llvm::DINode::FlagRValueReference;
1558
+ if (CGM.getLangOpts ().Optimize )
1559
+ SPFlags |= llvm::DISubprogram::SPFlagOptimized;
1558
1560
1559
1561
llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams (Method, Unit);
1560
1562
llvm::DISubprogram *SP = DBuilder.createMethod (
1561
1563
RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
1562
- MethodTy, /* isLocalToUnit=*/ false , /* isDefinition=*/ false , Virtuality,
1563
- VIndex, ThisAdjustment, ContainingType, Flags, CGM.getLangOpts ().Optimize ,
1564
+ MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
1564
1565
TParamsArray.get ());
1565
1566
1566
1567
SPCache[Method->getCanonicalDecl ()].reset (SP);
@@ -3168,6 +3169,7 @@ llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
3168
3169
llvm::DINodeArray TParamsArray;
3169
3170
StringRef Name, LinkageName;
3170
3171
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
3172
+ llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
3171
3173
SourceLocation Loc = GD.getDecl ()->getLocation ();
3172
3174
llvm::DIFile *Unit = getOrCreateFile (Loc);
3173
3175
llvm::DIScope *DContext = Unit;
@@ -3184,21 +3186,23 @@ llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
3184
3186
CallingConv CC = FD->getType ()->castAs <FunctionType>()->getCallConv ();
3185
3187
QualType FnType = CGM.getContext ().getFunctionType (
3186
3188
FD->getReturnType (), ArgTypes, FunctionProtoType::ExtProtoInfo (CC));
3189
+ if (!FD->isExternallyVisible ())
3190
+ SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
3191
+ if (CGM.getLangOpts ().Optimize )
3192
+ SPFlags |= llvm::DISubprogram::SPFlagOptimized;
3193
+
3187
3194
if (Stub) {
3188
3195
Flags |= getCallSiteRelatedAttrs ();
3196
+ SPFlags |= llvm::DISubprogram::SPFlagDefinition;
3189
3197
return DBuilder.createFunction (
3190
3198
DContext, Name, LinkageName, Unit, Line,
3191
- getOrCreateFunctionType (GD.getDecl (), FnType, Unit),
3192
- !FD->isExternallyVisible (),
3193
- /* isDefinition = */ true , 0 , Flags, CGM.getLangOpts ().Optimize ,
3199
+ getOrCreateFunctionType (GD.getDecl (), FnType, Unit), 0 , Flags, SPFlags,
3194
3200
TParamsArray.get (), getFunctionDeclaration (FD));
3195
3201
}
3196
3202
3197
3203
llvm::DISubprogram *SP = DBuilder.createTempFunctionFwdDecl (
3198
3204
DContext, Name, LinkageName, Unit, Line,
3199
- getOrCreateFunctionType (GD.getDecl (), FnType, Unit),
3200
- !FD->isExternallyVisible (),
3201
- /* isDefinition = */ false , 0 , Flags, CGM.getLangOpts ().Optimize ,
3205
+ getOrCreateFunctionType (GD.getDecl (), FnType, Unit), 0 , Flags, SPFlags,
3202
3206
TParamsArray.get (), getFunctionDeclaration (FD));
3203
3207
const FunctionDecl *CanonDecl = FD->getCanonicalDecl ();
3204
3208
FwdDeclReplaceMap.emplace_back (std::piecewise_construct,
@@ -3386,6 +3390,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
3386
3390
bool HasDecl = (D != nullptr );
3387
3391
3388
3392
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
3393
+ llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
3389
3394
llvm::DIFile *Unit = getOrCreateFile (Loc);
3390
3395
llvm::DIScope *FDContext = Unit;
3391
3396
llvm::DINodeArray TParamsArray;
@@ -3425,7 +3430,14 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
3425
3430
if (CurFuncIsThunk)
3426
3431
Flags |= llvm::DINode::FlagThunk;
3427
3432
3433
+ if (Fn->hasLocalLinkage ())
3434
+ SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
3435
+ if (CGM.getLangOpts ().Optimize )
3436
+ SPFlags |= llvm::DISubprogram::SPFlagOptimized;
3437
+
3428
3438
llvm::DINode::DIFlags FlagsForDef = Flags | getCallSiteRelatedAttrs ();
3439
+ llvm::DISubprogram::DISPFlags SPFlagsForDef =
3440
+ SPFlags | llvm::DISubprogram::SPFlagDefinition;
3429
3441
3430
3442
unsigned LineNo = getLineNumber (Loc);
3431
3443
unsigned ScopeLine = getLineNumber (ScopeLoc);
@@ -3437,9 +3449,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
3437
3449
// are emitted as CU level entities by the backend.
3438
3450
llvm::DISubprogram *SP = DBuilder.createFunction (
3439
3451
FDContext, Name, LinkageName, Unit, LineNo,
3440
- getOrCreateFunctionType (D, FnType, Unit), Fn->hasLocalLinkage (),
3441
- true /* definition*/ , ScopeLine, FlagsForDef, CGM.getLangOpts ().Optimize ,
3442
- TParamsArray.get (), getFunctionDeclaration (D));
3452
+ getOrCreateFunctionType (D, FnType, Unit), ScopeLine, FlagsForDef,
3453
+ SPFlagsForDef, TParamsArray.get (), getFunctionDeclaration (D));
3443
3454
Fn->setSubprogram (SP);
3444
3455
// We might get here with a VarDecl in the case we're generating
3445
3456
// code for the initialization of globals. Do not record these decls
@@ -3459,8 +3470,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
3459
3470
cast<llvm::DICompositeType>(It->second );
3460
3471
llvm::DISubprogram *FD = DBuilder.createFunction (
3461
3472
InterfaceDecl, Name, LinkageName, Unit, LineNo,
3462
- getOrCreateFunctionType (D, FnType, Unit), Fn->hasLocalLinkage (),
3463
- false /* definition*/ , ScopeLine, Flags, CGM.getLangOpts ().Optimize ,
3473
+ getOrCreateFunctionType (D, FnType, Unit), ScopeLine, Flags, SPFlags,
3464
3474
TParamsArray.get ());
3465
3475
DBuilder.finalizeSubprogram (FD);
3466
3476
ObjCMethodCache[ID].push_back (FD);
@@ -3509,11 +3519,13 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
3509
3519
}
3510
3520
unsigned LineNo = getLineNumber (Loc);
3511
3521
unsigned ScopeLine = 0 ;
3522
+ llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
3523
+ if (CGM.getLangOpts ().Optimize )
3524
+ SPFlags |= llvm::DISubprogram::SPFlagOptimized;
3512
3525
3513
3526
DBuilder.retainType (DBuilder.createFunction (
3514
3527
FDContext, Name, LinkageName, Unit, LineNo,
3515
- getOrCreateFunctionType (D, FnType, Unit), false /* internalLinkage*/ ,
3516
- false /* definition*/ , ScopeLine, Flags, CGM.getLangOpts ().Optimize ,
3528
+ getOrCreateFunctionType (D, FnType, Unit), ScopeLine, Flags, SPFlags,
3517
3529
TParamsArray.get (), getFunctionDeclaration (D)));
3518
3530
}
3519
3531
0 commit comments