SIL: Only enable instruction leaks checking in the frontend's and SILOpt's modules.

Leaks checking is not thread safe and e.g. lldb creates multiple SILModules in multiple threads, which would result in false alarms.
Ideally we would make it thread safe, e.g. by putting the instruction counters in the SILModule, but this would be a big effort and it's not worth doing it. Leaks checking in the frontend's and SILOpt's SILModule (not including SILModules created for module interface building) is a good enough test.

rdar://84688015
This commit is contained in:
Erik Eckstein
2021-10-29 21:05:22 +02:00
parent 2ad0eb7717
commit 5321a7cae8
8 changed files with 38 additions and 3 deletions

View File

@@ -151,6 +151,13 @@ SILModule::~SILModule() {
}
void SILModule::checkForLeaks() const {
/// Leak checking is not thread safe, because the instruction counters are
/// global non-atomic variables. Leak checking can only be done in case there
/// is a single SILModule in a single thread.
if (!getOptions().checkSILModuleLeaks)
return;
int instsInModule = std::distance(scheduledForDeletion.begin(),
scheduledForDeletion.end());
for (const SILFunction &F : *this) {