Skip to content

Also disable SwiftMergeFunctionsPass on top of LLVM MergeFunctions when VFE/WME is on #40016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/IRGen/IRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,15 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
llvm::createAlwaysInlinerLegacyPass(/*insertlifetime*/false);
}

// LLVM MergeFunctions doesn't understand the string in the metadata on calls
// in @llvm.type.checked.load intrinsics is important, and mis-compiles
// (mis-merge) unrelated functions.
if (Opts.VirtualFunctionElimination || Opts.WitnessMethodElimination)
bool RunSwiftMergeFunctions = true;

// LLVM MergeFunctions and SwiftMergeFunctions don't understand that the
// string in the metadata on calls in @llvm.type.checked.load intrinsics is
// semantically meaningful, and mis-compile (mis-merge) unrelated functions.
if (Opts.VirtualFunctionElimination || Opts.WitnessMethodElimination) {
PMBuilder.MergeFunctions = false;
RunSwiftMergeFunctions = false;
}

bool RunSwiftSpecificLLVMOptzns =
!Opts.DisableSwiftSpecificLLVMOptzns && !Opts.DisableLLVMOptzns;
Expand Down Expand Up @@ -274,7 +278,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
addSanitizerCoveragePass);
}
if (RunSwiftSpecificLLVMOptzns) {
if (RunSwiftSpecificLLVMOptzns && RunSwiftMergeFunctions) {
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
[&](const PassManagerBuilder &Builder, PassManagerBase &PM) {
if (Builder.OptLevel > 0) {
Expand Down