@@ -318,51 +318,6 @@ static bool isDebugValueOfAllocStack(DebugValueInst *dvi, AllocStackInst *asi) {
318
318
return sbi->getDest () == asi;
319
319
}
320
320
321
- // / Promote a DebugValue w/ address value to a DebugValue of non-address value.
322
- static void promoteDebugValueAddr (DebugValueInst *dvai, SILValue value,
323
- SILBuilderContext &ctx,
324
- InstructionDeleter &deleter) {
325
- assert (dvai->getOperand ()->getType ().isLoadable (*dvai->getFunction ()) &&
326
- " Unexpected promotion of address-only type!" );
327
- assert (value && " Expected valid value" );
328
-
329
- // Avoid inserting the same debug_value twice.
330
- //
331
- // We remove the di expression when comparing since:
332
- //
333
- // 1. dvai is on will always have the deref diexpr since it is on addresses.
334
- //
335
- // 2. We are only trying to delete debug_var that are on values... values will
336
- // never have an op_deref meaning that the comparison will always fail and
337
- // not serve out purpose here.
338
- auto dvaiWithoutDIExpr = dvai->getVarInfo ()->withoutDIExpr ();
339
- for (auto *use : value->getUses ()) {
340
- if (auto *dvi = dyn_cast<DebugValueInst>(use->getUser ())) {
341
- if (!dvi->hasAddrVal () && *dvi->getVarInfo () == dvaiWithoutDIExpr) {
342
- deleter.forceDelete (dvai);
343
- return ;
344
- }
345
- }
346
- }
347
-
348
- // Drop op_deref if dvai is actually a debug_value instruction
349
- auto varInfo = *dvai->getVarInfo ();
350
- if (isa<DebugValueInst>(dvai)) {
351
- auto &diExpr = varInfo.DIExpr ;
352
- // FIXME: There should always be a DIExpr starting with an op_deref here
353
- // The debug_value is attached to a pointer type, and those don't exist
354
- // in Swift, so they should always be dereferenced.
355
- // However, this rule is broken in a lot of spaces, so we have to leave
356
- // this check to recover from wrong info
357
- if (diExpr && diExpr.startsWithDeref ())
358
- diExpr.eraseElement (diExpr.element_begin ());
359
- }
360
-
361
- SILBuilderWithScope b (dvai, ctx);
362
- b.createDebugValue (dvai->getLoc (), value, std::move (varInfo));
363
- deleter.forceDelete (dvai);
364
- }
365
-
366
321
// / Returns true if \p I is a load which loads from \p ASI.
367
322
static bool isLoadFromStack (SILInstruction *i, AllocStackInst *asi) {
368
323
if (!isa<LoadInst>(i) && !isa<LoadBorrowInst>(i))
@@ -1172,14 +1127,8 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
1172
1127
continue ;
1173
1128
}
1174
1129
1175
- // Replace debug_value w/ address value with debug_value of
1176
- // the promoted value.
1177
- // if we have a valid value to use at this point. Otherwise we'll
1178
- // promote this when we deal with hooking up phis.
1130
+ // Debug values will automatically be salvaged, we can ignore them
1179
1131
if (auto *dvi = DebugValueInst::hasAddrVal (inst)) {
1180
- if (isDebugValueOfAllocStack (dvi, asi) && runningVals)
1181
- promoteDebugValueAddr (dvi, runningVals->value .replacement (asi, dvi),
1182
- ctx, deleter);
1183
1132
continue ;
1184
1133
}
1185
1134
@@ -1432,12 +1381,8 @@ void StackAllocationPromoter::fixBranchesAndUses(
1432
1381
// on.
1433
1382
SILBasicBlock *userBlock = user->getParent ();
1434
1383
1384
+ // Debug values will automatically be salvaged, we can ignore them
1435
1385
if (auto *dvi = DebugValueInst::hasAddrVal (user)) {
1436
- // Replace debug_value w/ address-type value with
1437
- // a new debug_value w/ promoted value.
1438
- auto def = getEffectiveLiveInValues (phiBlocks, userBlock);
1439
- promoteDebugValueAddr (dvi, def.replacement (asi, dvi), ctx, deleter);
1440
- ++NumInstRemoved;
1441
1386
continue ;
1442
1387
}
1443
1388
@@ -2036,14 +1981,10 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *asi) {
2036
1981
continue ;
2037
1982
}
2038
1983
2039
- // Replace debug_value w/ address value with debug_value of
2040
- // the promoted value.
1984
+ // Debug values will automatically be salvaged, we can ignore them
2041
1985
if (auto *dvi = DebugValueInst::hasAddrVal (inst)) {
2042
1986
if (isDebugValueOfAllocStack (dvi, asi)) {
2043
- if (runningVals) {
2044
- promoteDebugValueAddr (dvi, runningVals->value .replacement (asi, dvi),
2045
- ctx, deleter);
2046
- } else {
1987
+ if (!runningVals) {
2047
1988
// Drop debug_value of uninitialized void values.
2048
1989
assert (asi->getElementType ().isVoid () &&
2049
1990
" Expected initialization of non-void type!" );
0 commit comments