SILGen: Explicitly mark uninitialized locals with mark_uninitialized, and have DI only consider mark_uninitialized storage.

Have SILGen mark all variables bound from pattern bindings without initializers (and *only* ones without initializers) with mark_uninitialized [var] pseudo instructions. On the DI end, *only* consider mark_uninitialized instructions for DI analysis. This has many benefits:

- DI doesn't waste time analyzing locals that are trivially initialized in the original source code.
- DI doesn't try to mangle canonical SIL that has been inlined from transparent functions, which may have been optimized into a form DI isn't written to understand.

While we're here, fix an issue with DCE where it would try to kill unused MarkUninitialized instructions. Although MarkUninitialized has no side effects, it still is semantically important to raw SIL, and can't be killed.

Chris did most of the work here; I just finished updating tests and fixing bugs.

Swift SVN r13247
This commit is contained in:
Joe Groff
2014-01-31 22:50:21 +00:00
parent a610743064
commit 71379f5bad
14 changed files with 236 additions and 145 deletions

View File

@@ -65,10 +65,8 @@ DIMemoryObjectInfo::DIMemoryObjectInfo(SILInstruction *MI) {
// If this is a 'self' decl in an init method for a non-enum value, then we
// want to process the stored members of the struct/class elementwise.
if (MUI->getKind() != MarkUninitializedInst::GlobalVar) {
if (!isEnumSelf() && !isDelegatingInit())
IsSelfOfNonDelegatingInitializer = true;
}
if (isAnyInitSelf() && !isEnumSelf() && !isDelegatingInit())
IsSelfOfNonDelegatingInitializer = true;
}
// Compute the number of elements to track in this memory object.
@@ -807,7 +805,8 @@ void ElementUseCollector::collectClassSelfUses() {
assert(MUI->hasOneUse());
auto *TheStore = cast<StoreInst>((*MUI->use_begin())->getUser());
SILValue SelfBox = TheStore->getOperand(1);
assert(isa<AllocBoxInst>(SelfBox) || isa<AllocStackInst>(SelfBox));
assert(isa<MarkUninitializedInst>(SelfBox) || isa<AllocBoxInst>(SelfBox) ||
isa<AllocStackInst>(SelfBox));
// Okay, given that we have a proper setup, we walk the use chains of the self
// box to find any accesses to it. The possible uses are one of:
@@ -959,7 +958,8 @@ void ElementUseCollector::collectDelegatingClassInitSelfUses() {
assert(MUI->hasOneUse());
auto *TheStore = cast<StoreInst>((*MUI->use_begin())->getUser());
SILValue SelfBox = TheStore->getOperand(1);
assert(isa<AllocBoxInst>(SelfBox) || isa<AllocStackInst>(SelfBox));
assert(isa<MarkUninitializedInst>(SelfBox) || isa<AllocBoxInst>(SelfBox) ||
isa<AllocStackInst>(SelfBox));
// Okay, given that we have a proper setup, we walk the use chains of the self
// box to find any accesses to it. The possible uses are one of: