[MachineOutliner] Outline from linkonceodrs by default in LTO when -moutline is passed

Pass -enable-linkonceodr-outlining by default when LTO is enabled.

The outliner shouldn't compete with any sort of linker deduplication
on linkonceodr functions when LTO is enabled. Therefore, this behaviour
should be the default.

llvm-svn: 335504
This commit is contained in:
Jessica Paquette 2018-06-25 17:36:05 +00:00
parent 165e1101ff
commit 2c26d776e6
2 changed files with 12 additions and 0 deletions

View File

@ -1482,6 +1482,14 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
if (A->getOption().matches(options::OPT_moutline)) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-enable-machine-outliner");
// The outliner shouldn't compete with linkers that dedupe linkonceodr
// functions in LTO. Enable that behaviour by default when compiling with
// LTO.
if (getToolChain().getDriver().isUsingLTO()) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-enable-linkonceodr-outlining");
}
}
}
}

View File

@ -3,3 +3,7 @@
// ON: "-mllvm" "-enable-machine-outliner"
// RUN: %clang -target aarch64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
// OFF-NOT: "-mllvm" "-enable-machine-outliner"
// RUN: %clang -target aarch64 -moutline -flto=thin -S %s -### 2>&1 | FileCheck %s -check-prefix=FLTO
// FLTO: "-mllvm" "-enable-linkonceodr-outlining"
// RUN: %clang -target aarch64 -moutline -flto=full -S %s -### 2>&1 | FileCheck %s -check-prefix=TLTO
// TLTO: "-mllvm" "-enable-linkonceodr-outlining"