llvm.org GIT mirror llvm / 6409bd6
[PM] Simplify how we parse the outer layer of the pass pipeline text and remove an extra, redundant pass manager wrapping every run. I had kept seeing these when manually testing, but it was getting really annoying and was going to cause problems with overly eager invalidation. The root cause was an overly complex and unnecessary pile of code for parsing the outer layer of the pass pipeline. We can instead delegate most of this to the recursive pipeline parsing. I've added some somewhat more basic and precise tests to catch this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225253 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 4 years ago
3 changed file(s) with 51 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
33 ; may not be useful once it becomes the default or may get spread out into other
44 ; files, but for now this is just going to step the new process through its
55 ; paces.
6
7 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
8 ; RUN: -passes=no-op-module %s 2>&1 \
9 ; RUN: | FileCheck %s --check-prefix=CHECK-MODULE-PASS
10 ; CHECK-MODULE-PASS: Starting module pass manager
11 ; CHECK-MODULE-PASS-NEXT: Running module pass: NoOpModulePass
12 ; CHECK-MODULE-PASS-NEXT: Finished module pass manager run.
13
14 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
15 ; RUN: -passes=no-op-cgscc %s 2>&1 \
16 ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS
17 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
18 ; RUN: -passes='cgscc(no-op-cgscc)' %s 2>&1 \
19 ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS
20 ; CHECK-CGSCC-PASS: Starting module pass manager
21 ; CHECK-CGSCC-PASS-NEXT: Running module pass: ModuleToPostOrderCGSCCPassAdaptor
22 ; CHECK-CGSCC-PASS-NEXT: Running module analysis: CGSCCAnalysisManagerModuleProxy
23 ; CHECK-CGSCC-PASS-NEXT: Running module analysis: Lazy CallGraph Analysis
24 ; CHECK-CGSCC-PASS-NEXT: Starting CGSCC pass manager run.
25 ; CHECK-CGSCC-PASS-NEXT: Running CGSCC pass: NoOpCGSCCPass
26 ; CHECK-CGSCC-PASS-NEXT: Finished CGSCC pass manager run.
27 ; CHECK-CGSCC-PASS-NEXT: Finished module pass manager run.
28
29 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
30 ; RUN: -passes=no-op-function %s 2>&1 \
31 ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS
32 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
33 ; RUN: -passes='function(no-op-function)' %s 2>&1 \
34 ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS
35 ; CHECK-FUNCTION-PASS: Starting module pass manager
36 ; CHECK-FUNCTION-PASS-NEXT: Running module pass: ModuleToFunctionPassAdaptor
37 ; CHECK-FUNCTION-PASS-NEXT: Running module analysis: FunctionAnalysisManagerModuleProxy
38 ; CHECK-FUNCTION-PASS-NEXT: Starting function pass manager run.
39 ; CHECK-FUNCTION-PASS-NEXT: Running function pass: NoOpFunctionPass
40 ; CHECK-FUNCTION-PASS-NEXT: Finished function pass manager run.
41 ; CHECK-FUNCTION-PASS-NEXT: Finished module pass manager run.
642
743 ; RUN: opt -disable-output -debug-pass-manager -passes=print %s 2>&1 \
844 ; RUN: | FileCheck %s --check-prefix=CHECK-MODULE-PRINT
3333 ; CHECK-NESTED-TWO-NOOP-FP: Starting module pass manager
3434 ; CHECK-NESTED-TWO-NOOP-FP: Running module pass: ModuleToFunctionPassAdaptor
3535 ; CHECK-NESTED-TWO-NOOP-FP: Starting function pass manager
36 ; CHECK-NESTED-TWO-NOOP-FP: Running function pass: FunctionPassManager
37 ; CHECK-NESTED-TWO-NOOP-FP: Starting function pass manager
3836 ; CHECK-NESTED-TWO-NOOP-FP: Running function pass: NoOpFunctionPass
3937 ; CHECK-NESTED-TWO-NOOP-FP: Running function pass: NoOpFunctionPass
40 ; CHECK-NESTED-TWO-NOOP-FP: Finished function pass manager
4138 ; CHECK-NESTED-TWO-NOOP-FP: Finished function pass manager
4239 ; CHECK-NESTED-TWO-NOOP-FP: Finished module pass manager
4340
346346 // pre-populate the analysis managers with target-specific stuff?
347347 bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText,
348348 bool VerifyEachPass) {
349 // Look at the first entry to figure out which layer to start parsing at.
350 if (PipelineText.startswith("module("))
351 return parseModulePassPipeline(MPM, PipelineText, VerifyEachPass) &&
352 PipelineText.empty();
353 if (PipelineText.startswith("cgscc(")) {
354 CGSCCPassManager CGPM;
355 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass) ||
356 !PipelineText.empty())
357 return false;
358 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
359 return true;
360 }
361 if (PipelineText.startswith("function(")) {
362 FunctionPassManager FPM;
363 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass) ||
364 !PipelineText.empty())
365 return false;
366 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
367 return true;
368 }
369
370 // This isn't a direct pass manager name, look for the end of a pass name.
349 // By default, try to parse the pipeline as-if it were within an implicit
350 // 'module(...)' pass pipeline. If this will parse at all, it needs to
351 // consume the entire string.
352 if (parseModulePassPipeline(MPM, PipelineText, VerifyEachPass))
353 return PipelineText.empty();
354
355 // This isn't parsable as a module pipeline, look for the end of a pass name
356 // and directly drop down to that layer.
371357 StringRef FirstName =
372358 PipelineText.substr(0, PipelineText.find_first_of(",)"));
373 if (isModulePassName(FirstName))
374 return parseModulePassPipeline(MPM, PipelineText, VerifyEachPass) &&
375 PipelineText.empty();
376
359 assert(!isModulePassName(FirstName) &&
360 "Already handled all module pipeline options.");
361
362 // If this looks like a CGSCC pass, parse the whole thing as a CGSCC
363 // pipeline.
377364 if (isCGSCCPassName(FirstName)) {
378365 CGSCCPassManager CGPM;
379366 if (!parseCGSCCPassPipeline(CGPM, PipelineText, VerifyEachPass) ||
383370 return true;
384371 }
385372
373 // Similarly, if this looks like a Function pass, parse the whole thing as
374 // a Function pipelien.
386375 if (isFunctionPassName(FirstName)) {
387376 FunctionPassManager FPM;
388377 if (!parseFunctionPassPipeline(FPM, PipelineText, VerifyEachPass) ||