@@ -301,68 +301,6 @@ replaceDestroy(DestroyAddrInst *dai, SILValue newValue, SILBuilderContext &ctx,
301
301
prepareForDeletion (dai, instructionsToDelete);
302
302
}
303
303
304
- // / Whether the specified debug_value's operand names the address at the
305
- // / indicated alloc_stack.
306
- // /
307
- // / If it's a guaranteed alloc_stack (i.e. a store_borrow location), that
308
- // / includes the values produced by any store_borrows whose destinations are the
309
- // / alloc_stack since those values amount to aliases for the alloc_stack's
310
- // / storage.
311
- static bool isDebugValueOfAllocStack (DebugValueInst *dvi, AllocStackInst *asi) {
312
- auto value = dvi->getOperand ();
313
- if (value == asi)
314
- return true ;
315
- auto *sbi = dyn_cast<StoreBorrowInst>(value);
316
- if (!sbi)
317
- return false ;
318
- return sbi->getDest () == asi;
319
- }
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
304
// / Returns true if \p I is a load which loads from \p ASI.
367
305
static bool isLoadFromStack (SILInstruction *i, AllocStackInst *asi) {
368
306
if (!isa<LoadInst>(i) && !isa<LoadBorrowInst>(i))
@@ -1172,14 +1110,8 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
1172
1110
continue ;
1173
1111
}
1174
1112
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.
1113
+ // Debug values will automatically be salvaged, we can ignore them.
1179
1114
if (auto *dvi = DebugValueInst::hasAddrVal (inst)) {
1180
- if (isDebugValueOfAllocStack (dvi, asi) && runningVals)
1181
- promoteDebugValueAddr (dvi, runningVals->value .replacement (asi, dvi),
1182
- ctx, deleter);
1183
1115
continue ;
1184
1116
}
1185
1117
@@ -1432,12 +1364,8 @@ void StackAllocationPromoter::fixBranchesAndUses(
1432
1364
// on.
1433
1365
SILBasicBlock *userBlock = user->getParent ();
1434
1366
1367
+ // Debug values will automatically be salvaged, we can ignore them.
1435
1368
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
1369
continue ;
1442
1370
}
1443
1371
@@ -2036,20 +1964,8 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *asi) {
2036
1964
continue ;
2037
1965
}
2038
1966
2039
- // Replace debug_value w/ address value with debug_value of
2040
- // the promoted value.
1967
+ // Debug values will automatically be salvaged, we can ignore them.
2041
1968
if (auto *dvi = DebugValueInst::hasAddrVal (inst)) {
2042
- if (isDebugValueOfAllocStack (dvi, asi)) {
2043
- if (runningVals) {
2044
- promoteDebugValueAddr (dvi, runningVals->value .replacement (asi, dvi),
2045
- ctx, deleter);
2046
- } else {
2047
- // Drop debug_value of uninitialized void values.
2048
- assert (asi->getElementType ().isVoid () &&
2049
- " Expected initialization of non-void type!" );
2050
- deleter.forceDelete (dvi);
2051
- }
2052
- }
2053
1969
continue ;
2054
1970
}
2055
1971
0 commit comments