From: Jessica Paquette Date: Mon, 25 Jun 2018 17:36:05 +0000 (+0000) Subject: [MachineOutliner] Outline from linkonceodrs by default in LTO when -moutline is passed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f4f83642fbc23380edd820247831effe53a8cb9;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335504 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 248c460aa0..5cb3796723 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -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"); + } } } } diff --git a/test/Driver/aarch64-outliner.c b/test/Driver/aarch64-outliner.c index 311ee59901..dd2ae2a66c 100644 --- a/test/Driver/aarch64-outliner.c +++ b/test/Driver/aarch64-outliner.c @@ -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"