@@ -231,11 +231,15 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
231
231
llvm::createAlwaysInlinerLegacyPass (/* insertlifetime*/ false );
232
232
}
233
233
234
- // LLVM MergeFunctions doesn't understand the string in the metadata on calls
235
- // in @llvm.type.checked.load intrinsics is important, and mis-compiles
236
- // (mis-merge) unrelated functions.
237
- if (Opts.VirtualFunctionElimination || Opts.WitnessMethodElimination )
234
+ bool RunSwiftMergeFunctions = true ;
235
+
236
+ // LLVM MergeFunctions and SwiftMergeFunctions don't understand that the
237
+ // string in the metadata on calls in @llvm.type.checked.load intrinsics is
238
+ // semantically meaningful, and mis-compile (mis-merge) unrelated functions.
239
+ if (Opts.VirtualFunctionElimination || Opts.WitnessMethodElimination ) {
238
240
PMBuilder.MergeFunctions = false ;
241
+ RunSwiftMergeFunctions = false ;
242
+ }
239
243
240
244
bool RunSwiftSpecificLLVMOptzns =
241
245
!Opts.DisableSwiftSpecificLLVMOptzns && !Opts.DisableLLVMOptzns ;
@@ -274,7 +278,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
274
278
PMBuilder.addExtension (PassManagerBuilder::EP_EnabledOnOptLevel0,
275
279
addSanitizerCoveragePass);
276
280
}
277
- if (RunSwiftSpecificLLVMOptzns) {
281
+ if (RunSwiftSpecificLLVMOptzns && RunSwiftMergeFunctions ) {
278
282
PMBuilder.addExtension (PassManagerBuilder::EP_OptimizerLast,
279
283
[&](const PassManagerBuilder &Builder, PassManagerBase &PM) {
280
284
if (Builder.OptLevel > 0 ) {
0 commit comments