Skip to content

Commit e583f3a

Browse files
authored
Add -sil-cross-module-serialize-all option. (#30816)
Thanks, Michael!
1 parent d17cfbe commit e583f3a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/SILOptimizer/IPO/CrossModuleSerializationSetup.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#define DEBUG_TYPE "cross-module-serialization-setup"
18-
#include "swift/SILOptimizer/PassManager/Passes.h"
19-
#include "swift/SILOptimizer/PassManager/Transforms.h"
20-
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
18+
#include "swift/AST/Module.h"
2119
#include "swift/SIL/ApplySite.h"
20+
#include "swift/SIL/SILCloner.h"
2221
#include "swift/SIL/SILFunction.h"
2322
#include "swift/SIL/SILModule.h"
24-
#include "swift/SIL/SILCloner.h"
25-
#include "swift/AST/Module.h"
23+
#include "swift/SILOptimizer/PassManager/Passes.h"
24+
#include "swift/SILOptimizer/PassManager/Transforms.h"
25+
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
26+
#include "llvm/Support/CommandLine.h"
2627
#include "llvm/Support/Debug.h"
2728

2829
using namespace swift;
@@ -181,12 +182,19 @@ makeSubstUsableFromInline(const SubstitutionMap &substs) {
181182
}
182183
}
183184
}
185+
static llvm::cl::opt<bool> SerializeEverything(
186+
"sil-cross-module-serialize-all", llvm::cl::init(false),
187+
llvm::cl::desc(
188+
"Serialize everything when performing cross module optimization in "
189+
"order to investigate performance differences caused by different "
190+
"@inlinable, @usableFromInline choices."),
191+
llvm::cl::Hidden);
184192

185193
/// Decide whether to serialize a function.
186194
static bool shouldSerialize(SILFunction *F) {
187195
// The basic heursitic: serialize all generic functions, because it makes a
188196
// huge difference if generic functions can be specialized or not.
189-
if (!F->getLoweredFunctionType()->isPolymorphic())
197+
if (!F->getLoweredFunctionType()->isPolymorphic() && !SerializeEverything)
190198
return false;
191199

192200
// Check if we already handled this function before.

0 commit comments

Comments
 (0)