r368804 - [NewPM][PassInstrumentation] IR printing support from clang driver

Taewook Oh via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 14 00:11:09 PDT 2019


Author: twoh
Date: Wed Aug 14 00:11:09 2019
New Revision: 368804

URL: http://llvm.org/viewvc/llvm-project?rev=368804&view=rev
Log:
[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

Added:
    cfe/trunk/test/Misc/printer.c
Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=368804&r1=368803&r2=368804&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Aug 14 00:11:09 2019
@@ -37,6 +37,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Passes/PassPlugin.h"
+#include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -1063,7 +1064,10 @@ void EmitAssemblyHelper::EmitAssemblyWit
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
 
-  PassBuilder PB(TM.get(), PTO, PGOOpt);
+  PassInstrumentationCallbacks PIC;
+  StandardInstrumentations SI;
+  SI.registerCallbacks(PIC);
+  PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {

Added: cfe/trunk/test/Misc/printer.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/printer.c?rev=368804&view=auto
==============================================================================
--- cfe/trunk/test/Misc/printer.c (added)
+++ cfe/trunk/test/Misc/printer.c Wed Aug 14 00:11:09 2019
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-before-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER
+// CHECK-BEFORE: *** IR Dump Before AlwaysInlinerPass ***
+// CHECK-AFTER: *** IR Dump After AlwaysInlinerPass ***
+void foo() {}




More information about the cfe-commits mailing list