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

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 25 10:36:05 PDT 2018


Author: paquette
Date: Mon Jun 25 10:36:05 2018
New Revision: 335504

URL: http://llvm.org/viewvc/llvm-project?rev=335504&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/test/Driver/aarch64-outliner.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=335504&r1=335503&r2=335504&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jun 25 10:36:05 2018
@@ -1482,6 +1482,14 @@ void Clang::AddAArch64TargetArgs(const A
     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");
+      }
     }
   }
 }

Modified: cfe/trunk/test/Driver/aarch64-outliner.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-outliner.c?rev=335504&r1=335503&r2=335504&view=diff
==============================================================================
--- cfe/trunk/test/Driver/aarch64-outliner.c (original)
+++ cfe/trunk/test/Driver/aarch64-outliner.c Mon Jun 25 10:36:05 2018
@@ -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"




More information about the cfe-commits mailing list