mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user