@@ -295,8 +295,6 @@ class IRGenSILFunction :
295
295
// / Keeps track of the mapping of source variables to -O0 shadow copy allocas.
296
296
llvm::SmallDenseMap<std::pair<const SILDebugScope *, StringRef>, Address, 8 >
297
297
ShadowStackSlots;
298
- llvm::SmallDenseMap<Decl *, SmallString<4 >, 8 > AnonymousVariables;
299
- unsigned NumAnonVars = 0 ;
300
298
301
299
// / Accumulative amount of allocated bytes on the stack. Used to limit the
302
300
// / size for stack promoted objects.
@@ -483,26 +481,6 @@ class IRGenSILFunction :
483
481
return foundBB->second ;
484
482
}
485
483
486
- StringRef getOrCreateAnonymousVarName (VarDecl *Decl) {
487
- llvm::SmallString<4 > &Name = AnonymousVariables[Decl];
488
- if (Name.empty ()) {
489
- {
490
- llvm::raw_svector_ostream S (Name);
491
- S << ' _' << NumAnonVars++;
492
- }
493
- AnonymousVariables.insert ({Decl, Name});
494
- }
495
- return Name;
496
- }
497
-
498
- template <class DebugVarCarryingInst >
499
- StringRef getVarName (DebugVarCarryingInst *i) {
500
- StringRef Name = i->getVarInfo ().Name ;
501
- if (Name.empty () && i->getDecl ())
502
- return getOrCreateAnonymousVarName (i->getDecl ());
503
- return Name;
504
- }
505
-
506
484
// / At -O0, emit a shadow copy of an Address in an alloca, so the
507
485
// / register allocator doesn't elide the dbg.value intrinsic when
508
486
// / register pressure is high. There is a trade-off to this: With
@@ -609,8 +587,6 @@ class IRGenSILFunction :
609
587
610
588
void emitFunctionArgDebugInfo (SILBasicBlock *BB);
611
589
612
- void emitDebugInfoForAllocStack (AllocStackInst *i, const TypeInfo &type,
613
- llvm::Value *addr);
614
590
void visitAllocStackInst (AllocStackInst *i);
615
591
void visitAllocRefInst (AllocRefInst *i);
616
592
void visitAllocRefDynamicInst (AllocRefDynamicInst *i);
@@ -2973,7 +2949,7 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
2973
2949
if (isa<SILUndef>(SILVal))
2974
2950
return ;
2975
2951
2976
- StringRef Name = getVarName (i) ;
2952
+ StringRef Name = i-> getVarInfo (). Name ;
2977
2953
DebugTypeInfo DbgTy;
2978
2954
SILType SILTy = SILVal.getType ();
2979
2955
if (VarDecl *Decl = i->getDecl ())
@@ -3007,7 +2983,7 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
3007
2983
if (isa<SILUndef>(SILVal))
3008
2984
return ;
3009
2985
3010
- StringRef Name = getVarName (i) ;
2986
+ StringRef Name = i-> getVarInfo (). Name ;
3011
2987
auto Addr = getLoweredAddress (SILVal).getAddress ();
3012
2988
DebugTypeInfo DbgTy (Decl, Decl->getType (), getTypeInfo (SILVal.getType ()));
3013
2989
// Put the value into a stack slot at -Onone and emit a debug intrinsic.
@@ -3255,23 +3231,25 @@ static bool tryDeferFixedSizeBufferInitialization(IRGenSILFunction &IGF,
3255
3231
return false ;
3256
3232
}
3257
3233
3258
- void IRGenSILFunction::emitDebugInfoForAllocStack (AllocStackInst *i,
3259
- const TypeInfo &type,
3260
- llvm::Value *addr) {
3234
+ static void emitDebugDeclarationForAllocStack (IRGenSILFunction &IGF,
3235
+ AllocStackInst *i,
3236
+ const TypeInfo &type,
3237
+ llvm::Value *addr) {
3261
3238
VarDecl *Decl = i->getDecl ();
3262
- if (IGM.DebugInfo && Decl) {
3239
+ if (IGF. IGM .DebugInfo && Decl) {
3263
3240
auto *Pattern = Decl->getParentPattern ();
3264
3241
if (!Pattern || !Pattern->isImplicit ()) {
3265
3242
auto DbgTy = DebugTypeInfo (Decl, type);
3266
3243
// Discard any inout or lvalue qualifiers. Since the object itself
3267
3244
// is stored in the alloca, emitting it as a reference type would
3268
3245
// be wrong.
3269
3246
DbgTy.unwrapLValueOrInOutType ();
3270
- StringRef Name = getVarName (i);
3271
- if (auto DS = i->getDebugScope ()) {
3272
- assert (DS->SILFn == CurSILFn || DS->InlinedCallSite );
3273
- emitDebugVariableDeclaration (addr, DbgTy, DS, Name,
3274
- i->getVarInfo ().ArgNo );
3247
+ auto Name = i->getVarInfo ().Name .empty () ? " _" : i->getVarInfo ().Name ;
3248
+ auto DS = i->getDebugScope ();
3249
+ if (DS) {
3250
+ assert (DS->SILFn == IGF.CurSILFn || DS->InlinedCallSite );
3251
+ IGF.emitDebugVariableDeclaration (addr, DbgTy, DS, Name,
3252
+ i->getVarInfo ().ArgNo );
3275
3253
}
3276
3254
}
3277
3255
}
@@ -3285,7 +3263,7 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
3285
3263
StringRef dbgname;
3286
3264
# ifndef NDEBUG
3287
3265
// If this is a DEBUG build, use pretty names for the LLVM IR.
3288
- dbgname = getVarName (i) ;
3266
+ dbgname = i-> getVarInfo (). Name ;
3289
3267
# endif
3290
3268
3291
3269
(void ) Decl;
@@ -3302,8 +3280,10 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
3302
3280
auto addr = type.allocateStack (*this ,
3303
3281
i->getElementType (),
3304
3282
dbgname);
3305
-
3306
- emitDebugInfoForAllocStack (i, type, addr.getAddress ().getAddress ());
3283
+
3284
+ emitDebugDeclarationForAllocStack (*this , i, type,
3285
+ addr.getAddress ().getAddress ());
3286
+
3307
3287
setLoweredAddress (i->getContainerResult (), addr.getContainer ());
3308
3288
setLoweredAddress (i->getAddressResult (), addr.getAddress ());
3309
3289
}
@@ -3397,7 +3377,7 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
3397
3377
3398
3378
// Derive name from SIL location.
3399
3379
VarDecl *Decl = i->getDecl ();
3400
- StringRef Name = getVarName (i) ;
3380
+ StringRef Name = i-> getVarInfo (). Name ;
3401
3381
StringRef DbgName =
3402
3382
# ifndef NDEBUG
3403
3383
// If this is a DEBUG build, use pretty names for the LLVM IR.
@@ -4352,15 +4332,15 @@ void IRGenSILFunction::visitWitnessMethodInst(swift::WitnessMethodInst *i) {
4352
4332
4353
4333
void IRGenSILFunction::setAllocatedAddressForBuffer (SILValue v,
4354
4334
const Address &allocedAddress) {
4355
- assert (getLoweredValue (v).kind ==
4356
- LoweredValue::Kind::UnallocatedAddressInBuffer &&
4357
- " not an unallocated address" );
4358
-
4335
+ assert (getLoweredValue (v).kind == LoweredValue::Kind::UnallocatedAddressInBuffer
4336
+ && " not an unallocated address" );
4337
+
4359
4338
overwriteLoweredAddress (v, allocedAddress);
4360
4339
// Emit the debug info for the variable if any.
4361
4340
if (auto allocStack = dyn_cast<AllocStackInst>(v)) {
4362
- emitDebugInfoForAllocStack (allocStack, getTypeInfo (v.getType ()),
4363
- allocedAddress.getAddress ());
4341
+ emitDebugDeclarationForAllocStack (*this , allocStack,
4342
+ getTypeInfo (v.getType ()),
4343
+ allocedAddress.getAddress ());
4364
4344
}
4365
4345
}
4366
4346
0 commit comments