[llvm] 7a6a2cc - [LTO] Add option enable NewPM with LTOCodeGenerator.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 30 03:54:37 PST 2021


Author: Florian Hahn
Date: 2021-01-30T11:54:20Z
New Revision: 7a6a2cc81aaf064e6f5bc9a9a16973f552d2bdc2

URL: https://github.com/llvm/llvm-project/commit/7a6a2cc81aaf064e6f5bc9a9a16973f552d2bdc2
DIFF: https://github.com/llvm/llvm-project/commit/7a6a2cc81aaf064e6f5bc9a9a16973f552d2bdc2.diff

LOG: [LTO] Add option enable NewPM with LTOCodeGenerator.

This patch adds an option to enable the new pass manager in
LTOCodeGenerator. It also updates a few tests with legacy PM specific
tests, which started failing after 6a59f0560648 when
LLVM_ENABLE_NEW_PASS_MANAGER=true.

Added: 
    

Modified: 
    llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
    llvm/lib/LTO/LTOCodeGenerator.cpp
    llvm/test/LTO/X86/diagnostic-handler-remarks.ll
    llvm/test/LTO/X86/disable-verify.ll
    llvm/test/Other/X86/lto-hot-cold-split.ll
    llvm/tools/llvm-lto/llvm-lto.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
index b57c7daf758a..8a7c49e7fd22 100644
--- a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -186,6 +186,8 @@ struct LTOCodeGenerator {
 
   void setDisableVerify(bool Value) { DisableVerify = Value; }
 
+  void setUseNewPM(bool Value) { UseNewPM = Value; }
+
   void setDiagnosticHandler(lto_diagnostic_handler_t, void *);
 
   LLVMContext &getContext() { return Context; }
@@ -246,6 +248,7 @@ struct LTOCodeGenerator {
   bool Freestanding = false;
   std::unique_ptr<ToolOutputFile> StatsFile = nullptr;
   bool DisableVerify = false;
+  bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER;
 };
 }
 #endif

diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 180d906f506c..86c0906caa36 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -145,6 +145,7 @@ lto::Config LTOCodeGenerator::toConfig() const {
   Conf.PreCodeGenPassesHook = [](legacy::PassManager &PM) {
     PM.add(createObjCARCContractPass());
   };
+  Conf.UseNewPM = UseNewPM;
 
   return Conf;
 }

diff  --git a/llvm/test/LTO/X86/diagnostic-handler-remarks.ll b/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
index 6af6d8637c2e..f38293db93e1 100644
--- a/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
+++ b/llvm/test/LTO/X86/diagnostic-handler-remarks.ll
@@ -1,35 +1,41 @@
 ; RUN: llvm-as < %s >%t.bc
 ; PR21108: Diagnostic handlers get pass remarks, even if they're not enabled.
 
+; FIXME: Update checks for new pass manager.
+
 ; Confirm that there are -pass-remarks.
-; RUN: llvm-lto -pass-remarks=inline \
+; RUN: llvm-lto -use-new-pm=false \
+; RUN:          -pass-remarks=inline \
 ; RUN:          -exported-symbol _func2 -pass-remarks-analysis=loop-vectorize \
 ; RUN:          -exported-symbol _main -o %t.o %t.bc 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty -check-prefix=REMARKS
 ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
 
-; RUN: llvm-lto -pass-remarks=inline -use-diagnostic-handler \
+; RUN: llvm-lto -use-new-pm=false \
+; RUN:          -pass-remarks=inline -use-diagnostic-handler \
 ; RUN:          -exported-symbol _func2 -pass-remarks-analysis=loop-vectorize \
-; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
+; RUN:          -exported-symbol _main -o %t.o %t.bc 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty -check-prefix=REMARKS_DH
 ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
 
 ; Confirm that -pass-remarks are not printed by default.
-; RUN: llvm-lto \
+; RUN: llvm-lto -use-new-pm=false \
 ; RUN:         -exported-symbol _func2 \
 ; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty
 ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
 
-; RUN: llvm-lto -use-diagnostic-handler \
-; RUN:         -exported-symbol _func2 \
-; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
+; RUN: llvm-lto -use-new-pm=false \
+; RUN:          -use-diagnostic-handler \
+; RUN:          -exported-symbol _func2 \
+; RUN:          -exported-symbol _main -o %t.o %t.bc 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty
 ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
 
 ; Optimization records are collected regardless of the diagnostic handler
 ; RUN: rm -f %t.yaml
-; RUN: llvm-lto -lto-pass-remarks-output=%t.yaml \
+; RUN: llvm-lto -use-new-pm=false \
+; RUN:          -lto-pass-remarks-output=%t.yaml \
 ; RUN:          -exported-symbol _func2 \
 ; RUN:          -exported-symbol _main -o %t.o %t.bc 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty

diff  --git a/llvm/test/LTO/X86/disable-verify.ll b/llvm/test/LTO/X86/disable-verify.ll
index 0d507e67305e..8f34edad2cc6 100644
--- a/llvm/test/LTO/X86/disable-verify.ll
+++ b/llvm/test/LTO/X86/disable-verify.ll
@@ -1,6 +1,8 @@
 ; RUN: llvm-as < %s >%t.bc
-; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 -disable-verify | FileCheck %s
-; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 | FileCheck %s -check-prefix=VERIFY
+; RUN: llvm-lto -use-new-pm=false -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 -disable-verify | FileCheck %s
+; RUN: llvm-lto -use-new-pm=false -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 | FileCheck %s -check-prefix=VERIFY
+
+; FIXME: Update checks for new pass manager.
 
 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.10.0"

diff  --git a/llvm/test/Other/X86/lto-hot-cold-split.ll b/llvm/test/Other/X86/lto-hot-cold-split.ll
index 1c6a33df21c7..dda1437cbe85 100644
--- a/llvm/test/Other/X86/lto-hot-cold-split.ll
+++ b/llvm/test/Other/X86/lto-hot-cold-split.ll
@@ -1,6 +1,10 @@
 ; RUN: opt -module-summary %s -o %t.bc
-; RUN: llvm-lto -hot-cold-split=true -thinlto-action=run %t.bc -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=OLDPM-ANYLTO-POSTLINK-Os
-; RUN: llvm-lto -hot-cold-split=true %t.bc -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=OLDPM-ANYLTO-POSTLINK-Os
+; RUN: llvm-lto -use-new-pm=false -hot-cold-split=true \
+; RUN:          -thinlto-action=run %t.bc -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=OLDPM-ANYLTO-POSTLINK-Os
+; RUN: llvm-lto -use-new-pm=false -hot-cold-split=true \
+; RUN:          %t.bc -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=OLDPM-ANYLTO-POSTLINK-Os
+
+; FIXME: Update checks for new pass manager.
 
 ; REQUIRES: asserts
 

diff  --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index e7b09a44d9c0..027da28b30e2 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -222,6 +222,11 @@ static cl::opt<bool> PrintMachOCPUOnly(
     "print-macho-cpu-only", cl::init(false),
     cl::desc("Instead of running LTO, print the mach-o cpu in each IR file"));
 
+static cl::opt<bool>
+    UseNewPM("use-new-pm",
+             cl::desc("Run LTO passes using the new pass manager"),
+             cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden);
+
 namespace {
 
 struct ModuleInfo {
@@ -1014,6 +1019,8 @@ int main(int argc, char **argv) {
   CodeGen.setOptLevel(OptLevel - '0');
   CodeGen.setAttrs(codegen::getMAttrs());
 
+  CodeGen.setUseNewPM(UseNewPM);
+
   if (auto FT = codegen::getExplicitFileType())
     CodeGen.setFileType(FT.getValue());
 


        


More information about the llvm-commits mailing list