Skip to content

Commit d4c50f7

Browse files
committed
[NewPM][PassInstrumentation] IR printing support from clang driver
Summary: https://reviews.llvm.org/D50923 enabled the IR printing support for the new pass manager, but only for the case when `opt` tool is used as a driver. This patch is to enable the IR printing when `clang` is used as a driver. Reviewers: fedor.sergeev, philip.pfaffe Subscribers: cfe-commits, yamauchi, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65975 llvm-svn: 368804
1 parent afd493e commit d4c50f7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "llvm/MC/SubtargetFeature.h"
3838
#include "llvm/Passes/PassBuilder.h"
3939
#include "llvm/Passes/PassPlugin.h"
40+
#include "llvm/Passes/StandardInstrumentations.h"
4041
#include "llvm/Support/BuryPointer.h"
4142
#include "llvm/Support/CommandLine.h"
4243
#include "llvm/Support/MemoryBuffer.h"
@@ -1063,7 +1064,10 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
10631064
PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
10641065
PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
10651066

1066-
PassBuilder PB(TM.get(), PTO, PGOOpt);
1067+
PassInstrumentationCallbacks PIC;
1068+
StandardInstrumentations SI;
1069+
SI.registerCallbacks(PIC);
1070+
PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC);
10671071

10681072
// Attempt to load pass plugins and register their callbacks with PB.
10691073
for (auto &PluginFN : CodeGenOpts.PassPlugins) {

clang/test/Misc/printer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-before-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE
2+
// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER
3+
// CHECK-BEFORE: *** IR Dump Before AlwaysInlinerPass ***
4+
// CHECK-AFTER: *** IR Dump After AlwaysInlinerPass ***
5+
void foo() {}

0 commit comments

Comments
 (0)