@@ -292,9 +292,6 @@ class IRGenSILFunction :
292
292
293
293
// / All alloc_ref instructions which allocate the object on the stack.
294
294
llvm::SmallPtrSet<SILInstruction *, 8 > StackAllocs;
295
- // / Keeps track of the mapping of source variables to -O0 shadow copy allocas.
296
- llvm::SmallDenseMap<std::pair<const SILDebugScope *, StringRef>, Address, 8 >
297
- ShadowStackSlots;
298
295
299
296
// / Accumulative amount of allocated bytes on the stack. Used to limit the
300
297
// / size for stack promoted objects.
@@ -486,7 +483,6 @@ class IRGenSILFunction :
486
483
// / register pressure is high. There is a trade-off to this: With
487
484
// / shadow copies, we lose the precise lifetime.
488
485
llvm::Value *emitShadowCopy (llvm::Value *Storage,
489
- const SILDebugScope *Scope,
490
486
StringRef Name,
491
487
Alignment Align = Alignment(0 )) {
492
488
auto Ty = Storage->getType ();
@@ -499,21 +495,16 @@ class IRGenSILFunction :
499
495
if (Align.isZero ())
500
496
Align = IGM.getPointerAlignment ();
501
497
502
- auto &Alloca = ShadowStackSlots[{Scope, Name}];
503
- if (!Alloca.isValid ())
504
- Alloca = createAlloca (Ty, Align, Name+" .addr" );
498
+ auto Alloca = createAlloca (Ty, Align, Name+" .addr" );
505
499
Builder.CreateStore (Storage, Alloca.getAddress (), Align);
506
500
return Alloca.getAddress ();
507
501
}
508
502
509
- llvm::Value *emitShadowCopy (Address Storage, const SILDebugScope *Scope,
510
- StringRef Name) {
511
- return emitShadowCopy (Storage.getAddress (), Scope, Name,
512
- Storage.getAlignment ());
503
+ llvm::Value *emitShadowCopy (Address storage, StringRef name) {
504
+ return emitShadowCopy (storage.getAddress (), name, storage.getAlignment ());
513
505
}
514
506
515
- void emitShadowCopy (ArrayRef<llvm::Value *> vals, const SILDebugScope *scope,
516
- StringRef name,
507
+ void emitShadowCopy (ArrayRef<llvm::Value *> vals, StringRef name,
517
508
llvm::SmallVectorImpl<llvm::Value *> ©) {
518
509
// Only do this at -O0.
519
510
if (IGM.Opts .Optimize ) {
@@ -524,7 +515,7 @@ class IRGenSILFunction :
524
515
// Single or empty values.
525
516
if (vals.size () <= 1 ) {
526
517
for (auto val : vals)
527
- copy.push_back (emitShadowCopy (val, scope, name));
518
+ copy.push_back (emitShadowCopy (val, name));
528
519
return ;
529
520
}
530
521
@@ -1411,9 +1402,8 @@ void IRGenSILFunction::emitFunctionArgDebugInfo(SILBasicBlock *BB) {
1411
1402
unsigned ArgNo =
1412
1403
countArgs (CurSILFn->getDeclContext ()) + 1 + BB->getBBArgs ().size ();
1413
1404
IGM.DebugInfo ->emitVariableDeclaration (
1414
- Builder,
1415
- emitShadowCopy (ErrorResultSlot.getAddress (), getDebugScope (), Name),
1416
- DTI, getDebugScope (), Name, ArgNo, IndirectValue, ArtificialValue);
1405
+ Builder, emitShadowCopy (ErrorResultSlot.getAddress (), Name), DTI,
1406
+ getDebugScope (), Name, ArgNo, IndirectValue, ArtificialValue);
1417
1407
}
1418
1408
}
1419
1409
@@ -2945,29 +2935,24 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
2945
2935
if (!IGM.DebugInfo )
2946
2936
return ;
2947
2937
2938
+ VarDecl *Decl = i->getDecl ();
2939
+ if (!Decl)
2940
+ return ;
2941
+
2948
2942
auto SILVal = i->getOperand ();
2949
2943
if (isa<SILUndef>(SILVal))
2950
2944
return ;
2951
2945
2952
2946
StringRef Name = i->getVarInfo ().Name ;
2953
- DebugTypeInfo DbgTy;
2954
- SILType SILTy = SILVal.getType ();
2955
- if (VarDecl *Decl = i->getDecl ())
2956
- DbgTy = DebugTypeInfo (Decl, Decl->getType (), getTypeInfo (SILTy));
2957
- else if (i->getFunction ()->isBare () &&
2958
- !SILTy.getSwiftType ()->hasArchetype () && !Name.empty ())
2959
- // Preliminary support for .sil debug information.
2960
- DbgTy = DebugTypeInfo (SILTy.getSwiftType (), getTypeInfo (SILTy), nullptr );
2961
- else
2962
- return ;
2947
+ Explosion e = getLoweredExplosion (SILVal);
2948
+ DebugTypeInfo DbgTy (Decl, Decl->getType (), getTypeInfo (SILVal.getType ()));
2963
2949
// An inout/lvalue type that is described by a debug value has been
2964
2950
// promoted by an optimization pass. Unwrap the type.
2965
2951
DbgTy.unwrapLValueOrInOutType ();
2966
2952
2967
2953
// Put the value into a stack slot at -Onone.
2968
- llvm::SmallVector<llvm::Value *, 8 > Copy;
2969
- Explosion e = getLoweredExplosion (SILVal);
2970
- emitShadowCopy (e.claimAll (), i->getDebugScope (), Name, Copy);
2954
+ llvm::SmallVector<llvm::Value *, 8 > Copy;
2955
+ emitShadowCopy (e.claimAll (), Name, Copy);
2971
2956
emitDebugVariableDeclaration (Copy, DbgTy, i->getDebugScope (), Name,
2972
2957
i->getVarInfo ().ArgNo );
2973
2958
}
@@ -2987,9 +2972,9 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
2987
2972
auto Addr = getLoweredAddress (SILVal).getAddress ();
2988
2973
DebugTypeInfo DbgTy (Decl, Decl->getType (), getTypeInfo (SILVal.getType ()));
2989
2974
// Put the value into a stack slot at -Onone and emit a debug intrinsic.
2990
- emitDebugVariableDeclaration (
2991
- emitShadowCopy (Addr, i->getDebugScope (), Name), DbgTy ,
2992
- i-> getDebugScope (), Name, i->getVarInfo ().ArgNo , IndirectValue);
2975
+ emitDebugVariableDeclaration (emitShadowCopy (Addr, Name), DbgTy,
2976
+ i->getDebugScope (), Name,
2977
+ i->getVarInfo ().ArgNo , IndirectValue);
2993
2978
}
2994
2979
2995
2980
void IRGenSILFunction::visitLoadWeakInst (swift::LoadWeakInst *i) {
@@ -3405,7 +3390,7 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
3405
3390
return ;
3406
3391
3407
3392
IGM.DebugInfo ->emitVariableDeclaration (
3408
- Builder, emitShadowCopy (addr.getAddress (), i-> getDebugScope (), Name),
3393
+ Builder, emitShadowCopy (addr.getAddress (), Name),
3409
3394
DebugTypeInfo (Decl, i->getElementType ().getSwiftType (), type),
3410
3395
i->getDebugScope (), Name, 0 , IndirectValue);
3411
3396
}
0 commit comments