Skip to content

Commit b13eebe

Browse files
committedJun 29, 2017
[NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.
Differential Revision: https://reviews.llvm.org/D34790 llvm-svn: 306757
1 parent 6647069 commit b13eebe

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed
 

Diff for: ‎clang/include/clang/Driver/CC1Options.td

+4
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ def flto_unit: Flag<["-"], "flto-unit">,
323323
def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
324324
def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
325325
HelpText<"Write minimized bitcode to <file> for the ThinLTO thin link only">;
326+
def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
327+
HelpText<"Prints debug information for the new pass manager">;
328+
def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
329+
HelpText<"Disables debug printing for the new pass manager">;
326330

327331
//===----------------------------------------------------------------------===//
328332
// Dependency Output Options

Diff for: ‎clang/include/clang/Frontend/CodeGenOptions.def

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
5757
CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
5858
CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
5959
///< pass manager.
60+
CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
61+
///< pass manager.
6062
CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled.
6163
CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
6264
CODEGENOPT(EmitDeclMetadata , 1, 0) ///< Emit special metadata indicating what

Diff for: ‎clang/lib/CodeGen/BackendUtil.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
879879
PB.registerLoopAnalyses(LAM);
880880
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
881881

882-
ModulePassManager MPM;
882+
ModulePassManager MPM(CodeGenOpts.DebugPassManager);
883883

884884
if (!CodeGenOpts.DisableLLVMPasses) {
885885
bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
@@ -897,12 +897,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
897897
PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
898898

899899
if (IsThinLTO) {
900-
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
900+
MPM = PB.buildThinLTOPreLinkDefaultPipeline(
901+
Level, CodeGenOpts.DebugPassManager);
901902
MPM.addPass(NameAnonGlobalPass());
902903
} else if (IsLTO) {
903-
MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
904+
MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
905+
CodeGenOpts.DebugPassManager);
904906
} else {
905-
MPM = PB.buildPerModuleDefaultPipeline(Level);
907+
MPM = PB.buildPerModuleDefaultPipeline(Level,
908+
CodeGenOpts.DebugPassManager);
906909
}
907910
}
908911
}

Diff for: ‎clang/lib/Frontend/CompilerInvocation.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
476476
OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
477477
/* Default */ false);
478478

479+
Opts.DebugPassManager =
480+
Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
481+
/* Default */ false);
482+
479483
if (Arg *A = Args.getLastArg(OPT_fveclib)) {
480484
StringRef Name = A->getValue();
481485
if (Name == "Accelerate")

Diff for: ‎clang/test/CodeGen/lto-newpm-pipeline.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: x86-registered-target
2+
3+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O0 %s 2>&1 | FileCheck %s \
4+
// RUN: -check-prefix=CHECK-FULL-O0
5+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O0 %s 2>&1 | FileCheck %s \
6+
// RUN: -check-prefix=CHECK-THIN-O0
7+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O1 %s 2>&1 | FileCheck %s \
8+
// RUN: -check-prefix=CHECK-FULL-OPTIMIZED
9+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O1 %s 2>&1 | FileCheck %s \
10+
// RUN: -check-prefix=CHECK-THIN-OPTIMIZED
11+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O2 %s 2>&1 | FileCheck %s \
12+
// RUN: -check-prefix=CHECK-FULL-OPTIMIZED
13+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O2 %s 2>&1 | FileCheck %s \
14+
// RUN: -check-prefix=CHECK-THIN-OPTIMIZED
15+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O3 %s 2>&1 | FileCheck %s \
16+
// RUN: -check-prefix=CHECK-FULL-OPTIMIZED
17+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O3 %s 2>&1 | FileCheck %s \
18+
// RUN: -check-prefix=CHECK-THIN-OPTIMIZED
19+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -Os %s 2>&1 | FileCheck %s \
20+
// RUN: -check-prefix=CHECK-FULL-OPTIMIZED
21+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -Os %s 2>&1 | FileCheck %s \
22+
// RUN: -check-prefix=CHECK-THIN-OPTIMIZED
23+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -Oz %s 2>&1 | FileCheck %s \
24+
// RUN: -check-prefix=CHECK-FULL-OPTIMIZED
25+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -Oz %s 2>&1 | FileCheck %s \
26+
// RUN: -check-prefix=CHECK-THIN-OPTIMIZED
27+
28+
// CHECK-FULL-O0: Starting llvm::Module pass manager run.
29+
// CHECK-FULL-O0: Running pass: AlwaysInlinerPass
30+
// CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
31+
// CHECK-FULL-O0: Finished llvm::Module pass manager run.
32+
33+
// CHECK-THIN-O0: Starting llvm::Module pass manager run.
34+
// CHECK-THIN-O0: Running pass: AlwaysInlinerPass
35+
// CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
36+
// CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
37+
// CHECK-THIN-O0: Finished llvm::Module pass manager run.
38+
39+
// TODO: The LTO pre-link pipeline currently invokes
40+
// buildPerModuleDefaultPipeline(), which contains LoopVectorizePass.
41+
// This may change as the pipeline gets implemented.
42+
// CHECK-FULL-OPTIMIZED: Starting llvm::Function pass manager run.
43+
// CHECK-FULL-OPTIMIZED: Running pass: LoopVectorizePass
44+
// CHECK-FULL-OPTIMIZED: Running pass: BitcodeWriterPass
45+
46+
// The ThinLTO pre-link pipeline shouldn't contain passes like
47+
// LoopVectorizePass.
48+
// CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
49+
// CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
50+
// CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
51+
// CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
52+
53+
void Foo() {}

0 commit comments

Comments
 (0)
Please sign in to comment.