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
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");
+ }
}
}
}
// 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"