@@ -126,8 +126,6 @@ SILModule::SILModule(llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
126126
127127SILModule::~SILModule () {
128128#ifndef NDEBUG
129- checkForLeaks ();
130-
131129 NumSlabsAllocated += numAllocatedSlabs;
132130 assert (numAllocatedSlabs == freeSlabs.size () && " leaking slabs in SILModule" );
133131#endif
@@ -163,65 +161,6 @@ SILModule::~SILModule() {
163161 flushDeletedInsts ();
164162}
165163
166- void SILModule::checkForLeaks () const {
167-
168- // / Leak checking is not thread safe, because the instruction counters are
169- // / global non-atomic variables. Leak checking can only be done in case there
170- // / is a single SILModule in a single thread.
171- if (!getOptions ().checkSILModuleLeaks )
172- return ;
173-
174- int instsInModule = scheduledForDeletion.size ();
175-
176- for (const SILFunction &F : *this ) {
177- const SILFunction *sn = &F;
178- do {
179- for (const SILBasicBlock &block : *sn) {
180- instsInModule += std::distance (block.begin (), block.end ());
181- }
182- } while ((sn = sn->snapshots ) != nullptr );
183- }
184- for (const SILFunction &F : zombieFunctions) {
185- const SILFunction *sn = &F;
186- do {
187- for (const SILBasicBlock &block : F) {
188- instsInModule += std::distance (block.begin (), block.end ());
189- }
190- } while ((sn = sn->snapshots ) != nullptr );
191- }
192- for (const SILGlobalVariable &global : getSILGlobals ()) {
193- instsInModule += std::distance (global.StaticInitializerBlock .begin (),
194- global.StaticInitializerBlock .end ());
195- }
196-
197- int numAllocated = SILInstruction::getNumCreatedInstructions () -
198- SILInstruction::getNumDeletedInstructions ();
199-
200- if (numAllocated != instsInModule) {
201- llvm::errs () << " Leaking instructions!\n " ;
202- llvm::errs () << " Allocated instructions: " << numAllocated << ' \n ' ;
203- llvm::errs () << " Instructions in module: " << instsInModule << ' \n ' ;
204- llvm_unreachable (" leaking instructions" );
205- }
206-
207- assert (PlaceholderValue::getNumPlaceholderValuesAlive () == 0 &&
208- " leaking placeholders" );
209- }
210-
211- void SILModule::checkForLeaksAfterDestruction () {
212- // Disabled in release (non-assert) builds because this check fails in rare
213- // cases in lldb, causing crashes. rdar://70826934
214- #ifndef NDEBUG
215- int numAllocated = SILInstruction::getNumCreatedInstructions () -
216- SILInstruction::getNumDeletedInstructions ();
217-
218- if (numAllocated != 0 ) {
219- llvm::errs () << " Leaking " << numAllocated << " instructions!\n " ;
220- llvm_unreachable (" leaking instructions" );
221- }
222- #endif
223- }
224-
225164std::unique_ptr<SILModule> SILModule::createEmptyModule (
226165 llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
227166 Lowering::TypeConverter &TC, const SILOptions &Options,
0 commit comments