@@ -4869,7 +4869,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
4869
4869
CGBuilderTy &Builder,
4870
4870
const bool UsePointerValue) {
4871
4871
if (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ())
4872
- return EmitDef (VD, Storage, ArgNo, Builder, UsePointerValue);
4872
+ return EmitDeclareForHeterogeneousDwarf (VD, Storage, ArgNo, Builder,
4873
+ UsePointerValue);
4873
4874
4874
4875
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
4875
4876
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
@@ -5051,11 +5052,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
5051
5052
return D;
5052
5053
}
5053
5054
5054
- llvm::DILocalVariable *CGDebugInfo::EmitDef (const BindingDecl *BD,
5055
- llvm::Value *Storage,
5056
- std::optional<unsigned > ArgNo,
5057
- CGBuilderTy &Builder,
5058
- const bool UsePointerValue) {
5055
+ llvm::DILocalVariable *CGDebugInfo::EmitDeclareForHeterogeneousDwarf (
5056
+ const BindingDecl *BD, llvm::Value *Storage, std::optional<unsigned > ArgNo,
5057
+ CGBuilderTy &Builder, const bool UsePointerValue) {
5059
5058
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
5060
5059
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
5061
5060
if (BD->hasAttr <NoDebugAttr>())
@@ -5077,10 +5076,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const BindingDecl *BD,
5077
5076
CGM.getTypes ().ConvertTypeForMem (BD->getDecomposedDecl ()->getType ());
5078
5077
5079
5078
llvm::DIExprBuilder ExprBuilder (CGM.getLLVMContext ());
5080
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5081
- ExprBuilder.append <llvm::DIOp::Referrer>(Storage->getType ());
5082
- else
5083
- ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5079
+ ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5084
5080
ExprBuilder.append <llvm::DIOp::Deref>(DecomposedTy);
5085
5081
5086
5082
if (UsePointerValue) {
@@ -5129,25 +5125,16 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const BindingDecl *BD,
5129
5125
}
5130
5126
}
5131
5127
5132
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5133
- DBuilder.insertDef (
5134
- DBuilder.createBoundedLifetime (D, ExprBuilder.intoExpr ()), Storage,
5135
- llvm::DILocation::get (CGM.getLLVMContext (), Line, Column, Scope,
5136
- CurInlinedAt),
5137
- Builder.GetInsertBlock ());
5138
- else
5139
- DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5140
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5141
- Column, Scope, CurInlinedAt),
5142
- Builder.GetInsertBlock ());
5128
+ DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5129
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5130
+ Column, Scope, CurInlinedAt),
5131
+ Builder.GetInsertBlock ());
5143
5132
return D;
5144
5133
}
5145
5134
5146
- llvm::DILocalVariable *CGDebugInfo::EmitDef (const VarDecl *VD,
5147
- llvm::Value *Storage,
5148
- std::optional<unsigned > ArgNo,
5149
- CGBuilderTy &Builder,
5150
- const bool UsePointerValue) {
5135
+ llvm::DILocalVariable *CGDebugInfo::EmitDeclareForHeterogeneousDwarf (
5136
+ const VarDecl *VD, llvm::Value *Storage, std::optional<unsigned > ArgNo,
5137
+ CGBuilderTy &Builder, const bool UsePointerValue) {
5151
5138
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo () &&
5152
5139
" Call to EmitDef below ReducedDebugInfo" );
5153
5140
assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled () &&
@@ -5203,10 +5190,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5203
5190
CGM.getLLVMContext ());
5204
5191
5205
5192
llvm::DIExprBuilder ExprBuilder (CGM.getLLVMContext ());
5206
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5207
- ExprBuilder.append <llvm::DIOp::Referrer>(Storage->getType ());
5208
- else
5209
- ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5193
+ ExprBuilder.append <llvm::DIOp::Arg>(0u , Storage->getType ());
5210
5194
llvm::Type *ReferrerPointeeTy =
5211
5195
(!Name.empty () && VD->isEscapingByref ()) ? BlockPtrTy : VDMemTy;
5212
5196
if (UsePointerValue)
@@ -5249,12 +5233,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5249
5233
const RecordDecl *RD = RT->getDecl ();
5250
5234
if (RD->isUnion () && RD->isAnonymousStructOrUnion ()) {
5251
5235
llvm::DIExprBuilder UnionExprBuilder{ExprBuilder};
5252
- llvm::DIExpr *UnionDIExpr = nullptr ;
5253
- llvm::DIExpression *UnionDIExpression = nullptr ;
5254
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5255
- UnionDIExpr = UnionExprBuilder.intoExpr ();
5256
- else
5257
- UnionDIExpression = UnionExprBuilder.intoExpression ();
5236
+ llvm::DIExpression *UnionDIExpression = UnionExprBuilder.intoExpression ();
5258
5237
5259
5238
// GDB has trouble finding local variables in anonymous unions, so we emit
5260
5239
// artificial local variables for each of the members.
@@ -5278,18 +5257,11 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5278
5257
Flags | llvm::DINode::FlagArtificial, MS, FieldAlign);
5279
5258
5280
5259
// Insert an intrinsic into the current block.
5281
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5282
- DBuilder.insertDef (DBuilder.createBoundedLifetime (D, UnionDIExpr),
5283
- Storage,
5284
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5285
- Column, Scope, CurInlinedAt),
5286
- Builder.GetInsertBlock ());
5287
- else
5288
- DBuilder.insertDeclare (Storage, D, UnionDIExpression,
5289
- llvm::DILocation::get (CGM.getLLVMContext (),
5290
- Line, Column, Scope,
5291
- CurInlinedAt),
5292
- Builder.GetInsertBlock ());
5260
+ DBuilder.insertDeclare (Storage, D, UnionDIExpression,
5261
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5262
+ Column, Scope,
5263
+ CurInlinedAt),
5264
+ Builder.GetInsertBlock ());
5293
5265
}
5294
5266
}
5295
5267
}
@@ -5349,17 +5321,10 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD,
5349
5321
Align);
5350
5322
}
5351
5323
// Insert an intrinsic into the current block.
5352
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
5353
- DBuilder.insertDef (
5354
- DBuilder.createBoundedLifetime (D, ExprBuilder.intoExpr ()), Storage,
5355
- llvm::DILocation::get (CGM.getLLVMContext (), Line, Column, Scope,
5356
- CurInlinedAt),
5357
- Builder.GetInsertBlock ());
5358
- else
5359
- DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5360
- llvm::DILocation::get (CGM.getLLVMContext (), Line,
5361
- Column, Scope, CurInlinedAt),
5362
- Builder.GetInsertBlock ());
5324
+ DBuilder.insertDeclare (Storage, D, ExprBuilder.intoExpression (),
5325
+ llvm::DILocation::get (CGM.getLLVMContext (), Line,
5326
+ Column, Scope, CurInlinedAt),
5327
+ Builder.GetInsertBlock ());
5363
5328
5364
5329
llvm::Function *Parent = Builder.GetInsertBlock ()->getParent ();
5365
5330
assert (Parent->getSubprogram () && " expected DISubprogram" );
@@ -5374,7 +5339,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
5374
5339
const bool UsePointerValue) {
5375
5340
5376
5341
if (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ())
5377
- return EmitDef (BD, Storage, ArgNo, Builder, UsePointerValue);
5342
+ return EmitDeclareForHeterogeneousDwarf (BD, Storage, ArgNo, Builder,
5343
+ UsePointerValue);
5378
5344
5379
5345
assert (CGM.getCodeGenOpts ().hasReducedDebugInfo ());
5380
5346
assert (!LexicalBlockStack.empty () && " Region stack mismatch, stack empty!" );
@@ -5837,41 +5803,12 @@ llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
5837
5803
return GVE;
5838
5804
}
5839
5805
5840
- llvm::DIGlobalVariable *
5841
- CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
5842
- const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
5843
- StringRef LinkageName, llvm::dwarf::MemorySpace MS,
5844
- llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
5845
- assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ());
5846
-
5847
- llvm::DIGlobalVariable *GV = nullptr ;
5848
-
5849
- for (const auto *Field : RD->fields ()) {
5850
- llvm::DIType *FieldTy = getOrCreateType (Field->getType (), Unit);
5851
- StringRef FieldName = Field->getName ();
5852
-
5853
- // Ignore unnamed fields, but recurse into anonymous records.
5854
- if (FieldName.empty ()) {
5855
- if (const auto *RT = dyn_cast<RecordType>(Field->getType ()))
5856
- GV = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
5857
- RT->getDecl (), Unit, LineNo, LinkageName, MS, Var, DContext);
5858
- continue ;
5859
- }
5860
- // Use VarDecl's Tag, Scope and Line number.
5861
- GV = DBuilder.createGlobalVariable (DContext, FieldName, LinkageName, Unit,
5862
- LineNo, FieldTy, Var->hasLocalLinkage (),
5863
- MS);
5864
- Var->addDebugInfo (GV);
5865
- }
5866
- return GV;
5867
- }
5868
-
5869
5806
llvm::DIGlobalVariableExpression *
5870
- CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
5807
+ CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarf (
5871
5808
const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
5872
5809
StringRef LinkageName, llvm::dwarf::MemorySpace MS,
5873
5810
llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
5874
- assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpression ());
5811
+ assert (CGM.getCodeGenOpts ().isHeterogeneousDwarfEnabled ());
5875
5812
5876
5813
llvm::DIGlobalVariableExpression *GVE = nullptr ;
5877
5814
@@ -5882,7 +5819,7 @@ CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression(
5882
5819
// Ignore unnamed fields, but recurse into anonymous records.
5883
5820
if (FieldName.empty ()) {
5884
5821
if (const auto *RT = dyn_cast<RecordType>(Field->getType ()))
5885
- GVE = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
5822
+ GVE = CollectAnonRecordDeclsForHeterogeneousDwarf (
5886
5823
RT->getDecl (), Unit, LineNo, LinkageName, MS, Var, DContext);
5887
5824
continue ;
5888
5825
}
@@ -6239,7 +6176,6 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6239
6176
6240
6177
// Attempt to store one global variable for the declaration - even if we
6241
6178
// emit a lot of fields.
6242
- llvm::DIGlobalVariable *DGV = nullptr ;
6243
6179
llvm::DIGlobalVariableExpression *GVE = nullptr ;
6244
6180
6245
6181
// If this is an anonymous union then we'll want to emit a global
@@ -6251,12 +6187,8 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6251
6187
assert (RD->isAnonymousStructOrUnion () &&
6252
6188
" unnamed non-anonymous struct or union?" );
6253
6189
// FIXME(KZHURAVL): No tests for this path.
6254
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
6255
- DGV = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpr (
6256
- RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6257
- else
6258
- GVE = CollectAnonRecordDeclsForHeterogeneousDwarfDIExpression (
6259
- RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6190
+ GVE = CollectAnonRecordDeclsForHeterogeneousDwarf (
6191
+ RD, Unit, LineNo, LinkageName, MS, Var, DContext);
6260
6192
} else {
6261
6193
auto Align = getDeclAlignIfRequired (D, CGM.getContext ());
6262
6194
@@ -6267,38 +6199,14 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6267
6199
6268
6200
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations (D);
6269
6201
6270
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ()) {
6271
- DGV = DBuilder.createGlobalVariable (
6272
- DContext, DeclName, LinkageName, Unit, LineNo,
6273
- getOrCreateType (T, Unit), Var->hasLocalLinkage (), true ,
6274
- getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters,
6275
- MS, getDeclAlignIfRequired (D, CGM.getContext ()));
6276
-
6277
- // Create DIFragment.
6278
- llvm::DIFragment *Fragment = DBuilder.createFragment ();
6279
- SmallVector<llvm::Metadata *> LifetimeArgs;
6280
- LifetimeArgs.push_back (Fragment);
6281
-
6282
- // Create DILifetime and add to llvm.dbg.retainedNodes named metadata.
6283
- DBuilder.createComputedLifetime (DGV, ExprBuilder.intoExpr (),
6284
- LifetimeArgs);
6285
-
6286
- Var->setDbgDef (Fragment);
6287
-
6288
- } else {
6289
- GVE = DBuilder.createGlobalVariableExpression (
6290
- DContext, DeclName, LinkageName, Unit, LineNo,
6291
- getOrCreateType (T, Unit), Var->hasLocalLinkage (), true ,
6292
- ExprBuilder.intoExpression (),
6293
- getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters,
6294
- MS, Align, Annotations);
6295
- Var->addDebugInfo (GVE);
6296
- }
6202
+ GVE = DBuilder.createGlobalVariableExpression (
6203
+ DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType (T, Unit),
6204
+ Var->hasLocalLinkage (), true , ExprBuilder.intoExpression (),
6205
+ getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters, MS,
6206
+ Align, Annotations);
6207
+ Var->addDebugInfo (GVE);
6297
6208
}
6298
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ())
6299
- GV.reset (DGV);
6300
- else
6301
- DeclCache[D->getCanonicalDecl ()].reset (GVE);
6209
+ DeclCache[D->getCanonicalDecl ()].reset (GVE);
6302
6210
}
6303
6211
6304
6212
void CGDebugInfo::EmitGlobalVariable (const ValueDecl *VD, const APValue &Init) {
@@ -6462,22 +6370,11 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf(
6462
6370
ExprBuilder.append <llvm::DIOp::Constant>(
6463
6371
llvm::ConstantFP::get (CGM.getLLVMContext (), Init.getFloat ()));
6464
6372
6465
- if (CGM.getCodeGenOpts ().isHeterogeneousDwarfDIExpr ()) {
6466
- llvm::DIGlobalVariable *DGV = DBuilder.createGlobalVariable (
6467
- DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6468
- true , true , getOrCreateStaticDataMemberDeclarationOrNull (VarD),
6469
- TemplateParameters, MS, Align);
6470
-
6471
- DBuilder.createComputedLifetime (DGV, ExprBuilder.intoExpr (), {});
6472
-
6473
- GV.reset (DGV);
6474
- } else {
6475
- GV.reset (DBuilder.createGlobalVariableExpression (
6476
- DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6477
- true , true , ExprBuilder.intoExpression (),
6478
- getOrCreateStaticDataMemberDeclarationOrNull (VarD), TemplateParameters,
6479
- MS, Align));
6480
- }
6373
+ GV.reset (DBuilder.createGlobalVariableExpression (
6374
+ DContext, Name, StringRef (), Unit, getLineNumber (VD->getLocation ()), Ty,
6375
+ true , true , ExprBuilder.intoExpression (),
6376
+ getOrCreateStaticDataMemberDeclarationOrNull (VarD), TemplateParameters,
6377
+ MS, Align));
6481
6378
}
6482
6379
6483
6380
void CGDebugInfo::EmitExternalVariable (llvm::GlobalVariable *Var,
0 commit comments