[PATCH] D53294: [ThinLTO] Add an option to disable (thin)lto internalization.

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 07:32:40 PDT 2018


tejohnson added a comment.

In https://reviews.llvm.org/D53294#1276434, @trentxintong wrote:

> Address @tejohson's suggestion to add test cases.
>
> I've added 3/4 suggested scenarios and could not figure out how to add LTO with llvm-lto
>  More specifically, it seems to me that llvm-lto does not go through the runRegularLTO path
>  (where GVs are internalized) when processing LTO modules.


That's because llvm-lto invokes the old LTO API (i.e the interfaces in LTO/legacy/LTOCodeGenerator.h), whereas llvm-lto2 invokes the new LTO API (which includes runRegularLTO).

To invoke regular LTO instead of ThinLTO you should not use -module-summary with opt (see my comment in your new test attempting to do regular LTO). You should be able to test regular LTO with the old LTO API. I.e. your change to LTOCodeGenerator.h should cause LTOCodeGenerator::applyScopeRestrictions to exit before invoking internalizeModule.

Note that ThinLTO for both old and new LTO APIs invokes the same thinLTOInternalizeAndPromoteInIndex routine, it's only regular LTO that has very different support for doing the internalization.



================
Comment at: test/LTO/X86/internalize.ll:1
+; RUN: opt -module-summary %s -o %t1.bc
+
----------------
Don't use -module-summary for testing regular LTO. With a module summary, the invocations of llvm-lto2 below are both doing ThinLTO.


================
Comment at: test/ThinLTO/X86/internalize.ll:7
+; Test the enable-lto-internalization option by setting it to false.
+; enable-lto-internalization makes sure indices are not marked as internallinkage and therefore internalization does not happen.
+; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc -enable-lto-internalization=false -o -  --exported-symbol=foo | llvm-dis -o - | FileCheck %s --check-prefix=INTERNALIZE-OPTION-DISABLE
----------------
Nit: line length


================
Comment at: test/ThinLTO/X86/internalize.ll:17
+; Test the enable-lto-internalization option by setting it to false.
+; enable-lto-internalization makes sure indices are not marked as internallinkage and therefore internalization does not happen.
+; RUN: llvm-lto2 run %t1.bc -o %t.o -save-temps -enable-lto-internalization=false \
----------------
Nit: line length


Repository:
  rL LLVM

https://reviews.llvm.org/D53294





More information about the llvm-commits mailing list