@@ -4875,7 +4875,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
4875
4875
CGBuilderTy &Builder,
4876
4876
const bool UsePointerValue) {
4877
4877
if (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ())
4878
- return EmitDef (VD, Storage, ArgNo, Builder, UsePointerValue);
4878
+ return EmitDeclareForHeterogeneousDwarf (VD, Storage, ArgNo, Builder,
4879
+ UsePointerValue);
4879
4880
4880
4881
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
4881
4882
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
@@ -5057,11 +5058,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
5057
5058
return D;
5058
5059
}
5059
5060
5060
- llvm::DILocalVariable *CGDebugInfo::EmitDef (const BindingDecl *BD,
5061
- llvm::Value *Storage,
5062
- std::optional<unsigned > ArgNo,
5063
- CGBuilderTy &Builder,
5064
- const bool UsePointerValue) {
5061
+ llvm::DILocalVariable *CGDebugInfo::EmitDeclareForHeterogeneousDwarf (
5062
+ const BindingDecl *BD, llvm::Value *Storage, std::optional<unsigned > ArgNo,
5063
+ CGBuilderTy &Builder, const bool UsePointerValue) {
5065
5064
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
5066
5065
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
5067
5066
if (BD->hasAttr <NoDebugAttr>())
@@ -5083,10 +5082,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const BindingDecl *BD,
5083
5082
CGM.getTypes ().ConvertTypeForMem (BD->getDecomposedDecl ()->getType ());
5084
5083
5085
5084
llvm::DIExprBuilder ExprBuilder (CGM.getLLVMContext ());
5086
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5087
- ExprBuilder.append <llvm::DIOp::Referrer>(Storage->getType ());
5088
- else
5089
- ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5085
+ ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5090
5086
ExprBuilder.append <llvm::DIOp::Deref>(DecomposedTy);
5091
5087
5092
5088
if (UsePointerValue) {
@@ -5135,25 +5131,16 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const BindingDecl *BD,
5135
5131
}
5136
5132
}
5137
5133
5138
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5139
- DBuilder.insertDef (
5140
- DBuilder.createBoundedLifetime (D, ExprBuilder.intoExpr ()), Storage,
5141
- llvm::DILocation::get (CGM.getLLVMContext (), Line, Column, Scope,
5142
- CurInlinedAt),
5143
- Builder.GetInsertBlock ());
5144
- else
5145
- DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5146
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5147
- Column, Scope, CurInlinedAt),
5148
- Builder.GetInsertBlock ());
5134
+ DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5135
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5136
+ Column, Scope, CurInlinedAt),
5137
+ Builder.GetInsertBlock ());
5149
5138
return D;
5150
5139
}
5151
5140
5152
- llvm::DILocalVariable *CGDebugInfo::EmitDef (const VarDecl *VD,
5153
- llvm::Value *Storage,
5154
- std::optional<unsigned > ArgNo,
5155
- CGBuilderTy &Builder,
5156
- const bool UsePointerValue) {
5141
+ llvm::DILocalVariable *CGDebugInfo::EmitDeclareForHeterogeneousDwarf (
5142
+ const VarDecl *VD, llvm::Value *Storage, std::optional<unsigned > ArgNo,
5143
+ CGBuilderTy &Builder, const bool UsePointerValue) {
5157
5144
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo () &&
5158
5145
" Call to EmitDef below ReducedDebugInfo" );
5159
5146
assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled () &&
@@ -5209,10 +5196,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5209
5196
CGM.getLLVMContext ());
5210
5197
5211
5198
llvm::DIExprBuilder ExprBuilder (CGM.getLLVMContext ());
5212
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5213
- ExprBuilder.append <llvm::DIOp::Referrer>(Storage->getType ());
5214
- else
5215
- ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5199
+ ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5216
5200
llvm::Type *ReferrerPointeeTy =
5217
5201
(!Name.empty () && VD->isEscapingByref ()) ? BlockPtrTy : VDMemTy;
5218
5202
if (UsePointerValue)
@@ -5255,12 +5239,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5255
5239
const RecordDecl *RD = RT->getDecl ();
5256
5240
if (RD->isUnion () && RD->isAnonymousStructOrUnion ()) {
5257
5241
llvm::DIExprBuilder UnionExprBuilder{ExprBuilder};
5258
- llvm::DIExpr *UnionDIExpr = nullptr ;
5259
- llvm::DIExpression *UnionDIExpression = nullptr ;
5260
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5261
- UnionDIExpr = UnionExprBuilder.intoExpr ();
5262
- else
5263
- UnionDIExpression = UnionExprBuilder.intoExpression ();
5242
+ llvm::DIExpression *UnionDIExpression = UnionExprBuilder.intoExpression ();
5264
5243
5265
5244
// GDB has trouble finding local variables in anonymous unions, so we emit
5266
5245
// artificial local variables for each of the members.
@@ -5284,18 +5263,11 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5284
5263
Flags | llvm::DINode::FlagArtificial, MS, FieldAlign);
5285
5264
5286
5265
// Insert an intrinsic into the current block.
5287
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5288
- DBuilder.insertDef (DBuilder.createBoundedLifetime (D, UnionDIExpr),
5289
- Storage,
5290
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5291
- Column, Scope, CurInlinedAt),
5292
- Builder.GetInsertBlock ());
5293
- else
5294
- DBuilder.insertDeclare (Storage, D, UnionDIExpression,
5295
- llvm::DILocation::get (CGM.getLLVMContext (),
5296
- Line, Column, Scope,
5297
- CurInlinedAt),
5298
- Builder.GetInsertBlock ());
5266
+ DBuilder.insertDeclare (Storage, D, UnionDIExpression,
5267
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5268
+ Column, Scope,
5269
+ CurInlinedAt),
5270
+ Builder.GetInsertBlock ());
5299
5271
}
5300
5272
}
5301
5273
}
@@ -5355,17 +5327,10 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5355
5327
Align);
5356
5328
}
5357
5329
// Insert an intrinsic into the current block.
5358
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5359
- DBuilder.insertDef (
5360
- DBuilder.createBoundedLifetime (D, ExprBuilder.intoExpr ()), Storage,
5361
- llvm::DILocation::get (CGM.getLLVMContext (), Line, Column, Scope,
5362
- CurInlinedAt),
5363
- Builder.GetInsertBlock ());
5364
- else
5365
- DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5366
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5367
- Column, Scope, CurInlinedAt),
5368
- Builder.GetInsertBlock ());
5330
+ DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5331
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5332
+ Column, Scope, CurInlinedAt),
5333
+ Builder.GetInsertBlock ());
5369
5334
5370
5335
llvm::Function *Parent = Builder.GetInsertBlock ()->getParent ();
5371
5336
assert (Parent->getSubprogram () && " expected DISubprogram" );
@@ -5380,7 +5345,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
5380
5345
const bool UsePointerValue) {
5381
5346
5382
5347
if (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ())
5383
- return EmitDef (BD, Storage, ArgNo, Builder, UsePointerValue);
5348
+ return EmitDeclareForHeterogeneousDwarf (BD, Storage, ArgNo, Builder,
5349
+ UsePointerValue);
5384
5350
5385
5351
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
5386
5352
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
@@ -5843,41 +5809,12 @@ llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
5843
5809
return GVE;
5844
5810
}
5845
5811
5846
- llvm::DIGlobalVariable *
5847
- CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
5848
- const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
5849
- StringRef LinkageName, llvm::dwarf::MemorySpace MS,
5850
- llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
5851
- assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ());
5852
-
5853
- llvm::DIGlobalVariable *GV = nullptr ;
5854
-
5855
- for (const auto *Field : RD->fields ()) {
5856
- llvm::DIType *FieldTy = getOrCreateType (Field->getType (), Unit);
5857
- StringRef FieldName = Field->getName ();
5858
-
5859
- // Ignore unnamed fields, but recurse into anonymous records.
5860
- if (FieldName.empty ()) {
5861
- if (const auto *RT = dyn_cast<RecordType>(Field->getType ()))
5862
- GV = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
5863
- RT->getDecl (), Unit, LineNo, LinkageName, MS, Var, DContext);
5864
- continue ;
5865
- }
5866
- // Use VarDecl's Tag, Scope and Line number.
5867
- GV = DBuilder.createGlobalVariable (DContext, FieldName, LinkageName, Unit,
5868
- LineNo, FieldTy, Var->hasLocalLinkage (),
5869
- MS);
5870
- Var->addDebugInfo (GV);
5871
- }
5872
- return GV;
5873
- }
5874
-
5875
5812
llvm::DIGlobalVariableExpression *
5876
- CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
5813
+ CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarf (
5877
5814
const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
5878
5815
StringRef LinkageName, llvm::dwarf::MemorySpace MS,
5879
5816
llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
5880
- assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpression ());
5817
+ assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ());
5881
5818
5882
5819
llvm::DIGlobalVariableExpression *GVE = nullptr ;
5883
5820
@@ -5888,7 +5825,7 @@ CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression(
5888
5825
// Ignore unnamed fields, but recurse into anonymous records.
5889
5826
if (FieldName.empty ()) {
5890
5827
if (const auto *RT = dyn_cast<RecordType>(Field->getType ()))
5891
- GVE = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
5828
+ GVE = CollectAnonRecordDeclsForHeterogeneousDwarf (
5892
5829
RT->getDecl (), Unit, LineNo, LinkageName, MS, Var, DContext);
5893
5830
continue ;
5894
5831
}
@@ -6245,7 +6182,6 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6245
6182
6246
6183
// Attempt to store one global variable for the declaration - even if we
6247
6184
// emit a lot of fields.
6248
- llvm::DIGlobalVariable *DGV = nullptr ;
6249
6185
llvm::DIGlobalVariableExpression *GVE = nullptr ;
6250
6186
6251
6187
// If this is an anonymous union then we'll want to emit a global
@@ -6257,12 +6193,8 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6257
6193
assert (RD->isAnonymousStructOrUnion () &&
6258
6194
" unnamed non-anonymous struct or union?" );
6259
6195
// FIXME(KZHURAVL): No tests for this path.
6260
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
6261
- DGV = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
6262
- RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6263
- else
6264
- GVE = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
6265
- RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6196
+ GVE = CollectAnonRecordDeclsForHeterogeneousDwarf (
6197
+ RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6266
6198
} else {
6267
6199
auto Align = getDeclAlignIfRequired (D, CGM.getContext ());
6268
6200
@@ -6273,38 +6205,14 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6273
6205
6274
6206
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations (D);
6275
6207
6276
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ()) {
6277
- DGV = DBuilder.createGlobalVariable (
6278
- DContext, DeclName, LinkageName, Unit, LineNo,
6279
- getOrCreateType (T, Unit), Var->hasLocalLinkage (), true ,
6280
- getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters,
6281
- MS, getDeclAlignIfRequired (D, CGM.getContext ()));
6282
-
6283
- // Create DIFragment.
6284
- llvm::DIFragment *Fragment = DBuilder.createFragment ();
6285
- SmallVector<llvm::Metadata *> LifetimeArgs;
6286
- LifetimeArgs.push_back (Fragment);
6287
-
6288
- // Create DILifetime and add to llvm.dbg.retainedNodes named metadata.
6289
- DBuilder.createComputedLifetime (DGV, ExprBuilder.intoExpr (),
6290
- LifetimeArgs);
6291
-
6292
- Var->setDbgDef (Fragment);
6293
-
6294
- } else {
6295
- GVE = DBuilder.createGlobalVariableExpression (
6296
- DContext, DeclName, LinkageName, Unit, LineNo,
6297
- getOrCreateType (T, Unit), Var->hasLocalLinkage (), true ,
6298
- ExprBuilder.intoExpression (),
6299
- getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters,
6300
- MS, Align, Annotations);
6301
- Var->addDebugInfo (GVE);
6302
- }
6208
+ GVE = DBuilder.createGlobalVariableExpression (
6209
+ DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType (T, Unit),
6210
+ Var->hasLocalLinkage (), true , ExprBuilder.intoExpression (),
6211
+ getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters, MS,
6212
+ Align, Annotations);
6213
+ Var->addDebugInfo (GVE);
6303
6214
}
6304
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
6305
- GV.reset (DGV);
6306
- else
6307
- DeclCache[D->getCanonicalDecl ()].reset (GVE);
6215
+ DeclCache[D->getCanonicalDecl ()].reset (GVE);
6308
6216
}
6309
6217
6310
6218
void CGDebugInfo::EmitGlobalVariable (const ValueDecl *VD, const APValue &Init) {
@@ -6468,22 +6376,11 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6468
6376
ExprBuilder.append <llvm::DIOp::Constant>(
6469
6377
llvm::ConstantFP::get (CGM.getLLVMContext (), Init.getFloat ()));
6470
6378
6471
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ()) {
6472
- llvm::DIGlobalVariable *DGV = DBuilder.createGlobalVariable (
6473
- DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6474
- true , true , getOrCreateStaticDataMemberDeclarationOrNull (VarD),
6475
- TemplateParameters, MS, Align);
6476
-
6477
- DBuilder.createComputedLifetime (DGV, ExprBuilder.intoExpr (), {});
6478
-
6479
- GV.reset (DGV);
6480
- } else {
6481
- GV.reset (DBuilder.createGlobalVariableExpression (
6482
- DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6483
- true , true , ExprBuilder.intoExpression (),
6484
- getOrCreateStaticDataMemberDeclarationOrNull (VarD), TemplateParameters,
6485
- MS, Align));
6486
- }
6379
+ GV.reset (DBuilder.createGlobalVariableExpression (
6380
+ DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6381
+ true , true , ExprBuilder.intoExpression (),
6382
+ getOrCreateStaticDataMemberDeclarationOrNull (VarD), TemplateParameters,
6383
+ MS, Align));
6487
6384
}
6488
6385
6489
6386
void CGDebugInfo::EmitExternalVariable (llvm::GlobalVariable *Var,
0 commit comments