diff options
| author | Teresa Johnson <tejohnson@google.com> | 2019-04-23 18:56:19 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2019-04-23 18:56:19 +0000 |
| commit | 867bc3951bff977f930ca2451e9d1d3548587522 (patch) | |
| tree | b1bba0daf98be6c9cb2b85dd9e9fa1070fe903a1 /clang | |
| parent | 6967da8ffafe094507b153a93c607b95f2ab22a6 (diff) | |
| download | bcm5719-llvm-867bc3951bff977f930ca2451e9d1d3548587522.tar.gz bcm5719-llvm-867bc3951bff977f930ca2451e9d1d3548587522.zip | |
[ThinLTO] Pass down opt level to LTO backend and handle -O0 LTO in new PM
Summary:
The opt level was not being passed down to the ThinLTO backend when
invoked via clang (for distributed ThinLTO).
This exposed an issue where the new PM was asserting if the Thin or
regular LTO backend pipelines were invoked with -O0 (not a new issue,
could be provoked by invoking in-process *LTO backends via linker using
new PM and -O0). Fix this similar to the old PM where -O0 only does the
necessary lowering of type metadata (WPD and LowerTypeTest passes) and
then quits, rather than asserting.
Reviewers: xur
Subscribers: mehdi_amini, inglorion, eraman, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits, pcc
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D61022
llvm-svn: 359025
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 1 | ||||
| -rw-r--r-- | clang/test/CodeGen/thinlto-debug-pm.c | 15 | ||||
| -rw-r--r-- | clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll | 4 |
3 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 995df8c09da..51ee592c36d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1325,6 +1325,7 @@ static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M, Conf.MAttrs = TOpts.Features; Conf.RelocModel = CGOpts.RelocationModel; Conf.CGOptLevel = getCGOptLevel(CGOpts); + Conf.OptLevel = CGOpts.OptimizationLevel; initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts); Conf.SampleProfile = std::move(SampleProfile); diff --git a/clang/test/CodeGen/thinlto-debug-pm.c b/clang/test/CodeGen/thinlto-debug-pm.c index 2accde1f362..dc3bd33883f 100644 --- a/clang/test/CodeGen/thinlto-debug-pm.c +++ b/clang/test/CodeGen/thinlto-debug-pm.c @@ -1,10 +1,17 @@ -// Test to ensure -fdebug-pass-manager works when invoking the -// ThinLTO backend path with the new PM. +// Test to ensure the opt level is passed down to the ThinLTO backend. // REQUIRES: x86-registered-target // RUN: %clang_cc1 -o %t.o -flto=thin -fexperimental-new-pass-manager -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s // RUN: llvm-lto -thinlto -o %t %t.o -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -fexperimental-new-pass-manager 2>&1 | FileCheck %s -// CHECK: Running pass: + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O2-NEWPM +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O0-NEWPM +// O2-NEWPM: Running pass: LoopVectorizePass +// O0-NEWPM-NOT: Running pass: LoopVectorizePass + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm -debug-pass=Structure 2>&1 | FileCheck %s --check-prefix=O2-OLDPM +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm -debug-pass=Structure 2>&1 | FileCheck %s --check-prefix=O0-OLDPM +// O2-OLDPM: Loop Vectorization +// O0-OLDPM-NOT: Loop Vectorization void foo() { } diff --git a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll index 2ecf149b061..0bc23eb7733 100644 --- a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll +++ b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll @@ -39,12 +39,12 @@ ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi"))))) ; guid = 7004155349499253778 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \ -; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 \ ; RUN: -emit-llvm -o - -x ir %t.o | FileCheck %s --check-prefixes=CHECK-IR ; Check that backend does not fail generating native code. ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \ -; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 \ ; RUN: -o %t.native.o -x ir %t.o target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |

