[llvm] r369024 - [NewPM][PassInstrumentation] IR printing support for (Thin)LTO
Taewook Oh via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 10:47:44 PDT 2019
Author: twoh
Date: Thu Aug 15 10:47:44 2019
New Revision: 369024
URL: http://llvm.org/viewvc/llvm-project?rev=369024&view=rev
Log:
[NewPM][PassInstrumentation] IR printing support for (Thin)LTO
Summary: IR printing has not been correctly supported with (Thin)LTO if the new pass manager is enabled. Previously we only get outputs from backend(codegen) passes, as they are still under legacy pass manager even when the new pass manager is enabled. This patch addresses the issue and enables IR printing for optimization passes with new pass manager + (Thin)LTO setting.
Reviewers: fedor.sergeev, philip.pfaffe
Subscribers: mehdi_amini, inglorion, hiraditya, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66253
Added:
llvm/trunk/test/ThinLTO/X86/printer.ll
Modified:
llvm/trunk/lib/LTO/LTOBackend.cpp
Modified: llvm/trunk/lib/LTO/LTOBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOBackend.cpp?rev=369024&r1=369023&r2=369024&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp (original)
+++ llvm/trunk/lib/LTO/LTOBackend.cpp Thu Aug 15 10:47:44 2019
@@ -28,6 +28,7 @@
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Object/ModuleSymbolTable.h"
#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -165,7 +166,10 @@ static void runNewPMPasses(Config &Conf,
PGOOptions::IRUse, PGOOptions::CSIRUse);
}
- PassBuilder PB(TM, PipelineTuningOptions(), PGOOpt);
+ PassInstrumentationCallbacks PIC;
+ StandardInstrumentations SI;
+ SI.registerCallbacks(PIC);
+ PassBuilder PB(TM, PipelineTuningOptions(),PGOOpt, &PIC);
AAManager AA;
// Parse a custom AA pipeline if asked to.
Added: llvm/trunk/test/ThinLTO/X86/printer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/printer.ll?rev=369024&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/printer.ll (added)
+++ llvm/trunk/test/ThinLTO/X86/printer.ll Thu Aug 15 10:47:44 2019
@@ -0,0 +1,12 @@
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-lto2 run -r=%t.bc,foo,pxl -use-new-pm --print-before-all %t.bc -o - 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE
+; RUN: llvm-lto2 run -r=%t.bc,foo,pxl -use-new-pm --print-after-all %t.bc -o - 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER
+; CHECK-BEFORE: *** IR Dump Before GlobalDCEPass ***
+; CHECK-AFTER: *** IR Dump After GlobalDCEPass ***
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() {
+ ret i32 42
+}
More information about the llvm-commits
mailing list