Skip to content

Commit afe116b

Browse files
authored
Also disable SwiftMergeFunctionsPass on top of LLVM MergeFunctions when VFE/WME is on (#40016)
1 parent ebe93b8 commit afe116b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,15 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
231231
llvm::createAlwaysInlinerLegacyPass(/*insertlifetime*/false);
232232
}
233233

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) {
238240
PMBuilder.MergeFunctions = false;
241+
RunSwiftMergeFunctions = false;
242+
}
239243

240244
bool RunSwiftSpecificLLVMOptzns =
241245
!Opts.DisableSwiftSpecificLLVMOptzns && !Opts.DisableLLVMOptzns;
@@ -274,7 +278,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
274278
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
275279
addSanitizerCoveragePass);
276280
}
277-
if (RunSwiftSpecificLLVMOptzns) {
281+
if (RunSwiftSpecificLLVMOptzns && RunSwiftMergeFunctions) {
278282
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
279283
[&](const PassManagerBuilder &Builder, PassManagerBase &PM) {
280284
if (Builder.OptLevel > 0) {

0 commit comments

Comments
 (0)