Skip to content

Commit be3cec7

Browse files
committed
Revert "Debug Info: Support updates to debug values."
This reverts commit fd6e8a9 while investigating buildbot breakage. This uncovered a bug in the debug scoping of pattern match variables.
1 parent 97332af commit be3cec7

File tree

2 files changed

+19
-81
lines changed

2 files changed

+19
-81
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ class IRGenSILFunction :
292292

293293
/// All alloc_ref instructions which allocate the object on the stack.
294294
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;
298295

299296
/// Accumulative amount of allocated bytes on the stack. Used to limit the
300297
/// size for stack promoted objects.
@@ -486,7 +483,6 @@ class IRGenSILFunction :
486483
/// register pressure is high. There is a trade-off to this: With
487484
/// shadow copies, we lose the precise lifetime.
488485
llvm::Value *emitShadowCopy(llvm::Value *Storage,
489-
const SILDebugScope *Scope,
490486
StringRef Name,
491487
Alignment Align = Alignment(0)) {
492488
auto Ty = Storage->getType();
@@ -499,21 +495,16 @@ class IRGenSILFunction :
499495
if (Align.isZero())
500496
Align = IGM.getPointerAlignment();
501497

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");
505499
Builder.CreateStore(Storage, Alloca.getAddress(), Align);
506500
return Alloca.getAddress();
507501
}
508502

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());
513505
}
514506

515-
void emitShadowCopy(ArrayRef<llvm::Value *> vals, const SILDebugScope *scope,
516-
StringRef name,
507+
void emitShadowCopy(ArrayRef<llvm::Value *> vals, StringRef name,
517508
llvm::SmallVectorImpl<llvm::Value *> &copy) {
518509
// Only do this at -O0.
519510
if (IGM.Opts.Optimize) {
@@ -524,7 +515,7 @@ class IRGenSILFunction :
524515
// Single or empty values.
525516
if (vals.size() <= 1) {
526517
for (auto val : vals)
527-
copy.push_back(emitShadowCopy(val, scope, name));
518+
copy.push_back(emitShadowCopy(val, name));
528519
return;
529520
}
530521

@@ -1411,9 +1402,8 @@ void IRGenSILFunction::emitFunctionArgDebugInfo(SILBasicBlock *BB) {
14111402
unsigned ArgNo =
14121403
countArgs(CurSILFn->getDeclContext()) + 1 + BB->getBBArgs().size();
14131404
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);
14171407
}
14181408
}
14191409

@@ -2945,29 +2935,24 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
29452935
if (!IGM.DebugInfo)
29462936
return;
29472937

2938+
VarDecl *Decl = i->getDecl();
2939+
if (!Decl)
2940+
return;
2941+
29482942
auto SILVal = i->getOperand();
29492943
if (isa<SILUndef>(SILVal))
29502944
return;
29512945

29522946
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()));
29632949
// An inout/lvalue type that is described by a debug value has been
29642950
// promoted by an optimization pass. Unwrap the type.
29652951
DbgTy.unwrapLValueOrInOutType();
29662952

29672953
// 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);
29712956
emitDebugVariableDeclaration(Copy, DbgTy, i->getDebugScope(), Name,
29722957
i->getVarInfo().ArgNo);
29732958
}
@@ -2987,9 +2972,9 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
29872972
auto Addr = getLoweredAddress(SILVal).getAddress();
29882973
DebugTypeInfo DbgTy(Decl, Decl->getType(), getTypeInfo(SILVal.getType()));
29892974
// 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);
29932978
}
29942979

29952980
void IRGenSILFunction::visitLoadWeakInst(swift::LoadWeakInst *i) {
@@ -3405,7 +3390,7 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
34053390
return;
34063391

34073392
IGM.DebugInfo->emitVariableDeclaration(
3408-
Builder, emitShadowCopy(addr.getAddress(), i->getDebugScope(), Name),
3393+
Builder, emitShadowCopy(addr.getAddress(), Name),
34093394
DebugTypeInfo(Decl, i->getElementType().getSwiftType(), type),
34103395
i->getDebugScope(), Name, 0, IndirectValue);
34113396
}

test/DebugInfo/value-update.sil

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)