From 41e3d0fc23faed1eb34fd11bfbf8ea72e881ec22 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 21 Nov 2013 00:09:35 +0000 Subject: [PATCH] Re-commit Stephen's patch: Enable capture promotion pass by default This fixes up various testcases. Note that 3 debug info tests are asserting in IRGen for a common but unknown-to-me reason, I've XFAILed them for now. Swift SVN r10613 --- lib/SILPasses/DefiniteInitialization.cpp | 12 ++---------- tools/swift/Helpers.cpp | 1 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/SILPasses/DefiniteInitialization.cpp b/lib/SILPasses/DefiniteInitialization.cpp index cfdce0eecdf..64e5ff56d59 100644 --- a/lib/SILPasses/DefiniteInitialization.cpp +++ b/lib/SILPasses/DefiniteInitialization.cpp @@ -956,21 +956,13 @@ bool ElementPromotion::processNonTrivialRelease(SILInstruction *Inst) { return true; } - - // If the element type of the memory object is a class value - - // Okay, the release is conditionally live. We have to force it up the CFG to // a place where we have unconditional liveness, and if the memory object is a // tuple, we have to do so for each element individually. - /// TODO: We could make this more powerful to directly support these - /// cases, at least when the value doesn't escape. - /// - /// When this gets fixed, the code in the ~ElementUseCollector() method - /// can be removed. - /// + + // This is a release of an uninitialized value. Emit a diagnostic. diagnoseInitError(MemoryUse(Inst, UseKind::Load, 0, 0), diag::variable_destroyed_before_initialized); diff --git a/tools/swift/Helpers.cpp b/tools/swift/Helpers.cpp index 6b6ae4172b4..982a79b4d9b 100644 --- a/tools/swift/Helpers.cpp +++ b/tools/swift/Helpers.cpp @@ -54,6 +54,7 @@ bool swift::runSILDiagnosticPasses(SILModule &Module) { performSILMandatoryInlining(&Module); + performSILCapturePromotion(&Module); performSILAllocBoxToStackPromotion(&Module); performInOutDeshadowing(&Module); performSILDefiniteInitialization(&Module);