Enable dead function removal for internal function in whole-module compilation.

This is controlled by a new isWholeModule() attribute in SILModule.

It gives about 9% code size reduction on the benchmark executables.
For test-suite reasons it is currently not done for the stdlib.



Swift SVN r22491
This commit is contained in:
Erik Eckstein
2014-10-03 14:14:23 +00:00
parent 60dcb9a435
commit 43f68b6974
19 changed files with 147 additions and 50 deletions

View File

@@ -475,6 +475,8 @@ class MandatoryInlining : public SILModuleTransform {
if (!ShouldCleanup)
return;
bool isWholeModule = M->isWholeModule();
// Now that we've inlined some functions, clean up. If there are any
// transparent functions that are deserialized from another module that are
// now unused, just remove them from the module.
@@ -496,8 +498,13 @@ class MandatoryInlining : public SILModuleTransform {
// We discard functions that don't have external linkage,
// e.g. deserialized functions, internal functions, and thunks.
// Being marked transparent controls this.
if (isPossiblyUsedExternally(F.getLinkage())) continue;
if (isPossiblyUsedExternally(F.getLinkage(), isWholeModule)) continue;
// ObjC functions are called through the runtime and are therefore alive
// even if not referenced inside SIL.
if (F.getLoweredFunctionType()->getAbstractCC() == AbstractCC::ObjCMethod)
continue;
// Okay, just erase the function from the module.
M->eraseFunction(&F);
}