From 4a349f93973deb95d69b8a7f9344a66eedf4f16d Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 22 Jan 2021 17:25:18 -0800 Subject: [PATCH 1/2] SIL: Gate checkForLeaksAfterDestruction to asserts builds --- lib/SIL/IR/SILModule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/SIL/IR/SILModule.cpp b/lib/SIL/IR/SILModule.cpp index 22bcbe9f1ac35..87f798383301e 100644 --- a/lib/SIL/IR/SILModule.cpp +++ b/lib/SIL/IR/SILModule.cpp @@ -167,6 +167,7 @@ void SILModule::checkForLeaks() const { } void SILModule::checkForLeaksAfterDestruction() { +#ifndef NDEBUG int numAllocated = SILInstruction::getNumCreatedInstructions() - SILInstruction::getNumDeletedInstructions(); @@ -174,6 +175,7 @@ void SILModule::checkForLeaksAfterDestruction() { llvm::errs() << "Leaking " << numAllocated << " instructions!\n"; llvm_unreachable("leaking instructions"); } +#endif } std::unique_ptr SILModule::createEmptyModule( From 9760533fe2f28e1d2afc4d47bba3a76d5ea737c1 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 26 Jan 2021 12:40:14 -0800 Subject: [PATCH 2/2] add explanatory comment --- lib/SIL/IR/SILModule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/SIL/IR/SILModule.cpp b/lib/SIL/IR/SILModule.cpp index 87f798383301e..fbe26a3d4c7e5 100644 --- a/lib/SIL/IR/SILModule.cpp +++ b/lib/SIL/IR/SILModule.cpp @@ -167,6 +167,8 @@ void SILModule::checkForLeaks() const { } void SILModule::checkForLeaksAfterDestruction() { +// Disabled in release (non-assert) builds because this check fails in rare +// cases in lldb, causing crashes. rdar://70826934 #ifndef NDEBUG int numAllocated = SILInstruction::getNumCreatedInstructions() - SILInstruction::getNumDeletedInstructions();