From: Chandler Carruth Date: Sat, 11 Jan 2014 12:06:47 +0000 (+0000) Subject: [PM] Actually nest pass managers correctly when parsing the pass X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=08be87bdfa834371299c590f6042671df3abfd8a;p=oota-llvm.git [PM] Actually nest pass managers correctly when parsing the pass pipeline string. Add tests that cover this now that we have execution dumping in the pass managers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199005 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Other/pass-pipeline-parsing.ll b/test/Other/pass-pipeline-parsing.ll index c490f56ba84..20d39c78d37 100644 --- a/test/Other/pass-pipeline-parsing.ll +++ b/test/Other/pass-pipeline-parsing.ll @@ -1,2 +1,18 @@ -; RUN: opt -disable-output -passes=no-op-module,no-op-module %s -; RUN: opt -disable-output -passes='module(no-op-module,no-op-module)' %s +; RUN: opt -disable-output -debug-pass-manager \ +; RUN: -passes=no-op-module,no-op-module %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-TWO-NOOP-MP +; CHECK-TWO-NOOP-MP: Starting module pass manager +; CHECK-TWO-NOOP-MP: Running module pass: NoOpModulePass +; CHECK-TWO-NOOP-MP: Running module pass: NoOpModulePass +; CHECK-TWO-NOOP-MP: Finished module pass manager + +; RUN: opt -disable-output -debug-pass-manager \ +; RUN: -passes='module(no-op-module,no-op-module)' %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-NESTED-TWO-NOOP-MP +; CHECK-NESTED-TWO-NOOP-MP: Starting module pass manager +; CHECK-NESTED-TWO-NOOP-MP: Running module pass: ModulePassManager +; CHECK-NESTED-TWO-NOOP-MP: Starting module pass manager +; CHECK-NESTED-TWO-NOOP-MP: Running module pass: NoOpModulePass +; CHECK-NESTED-TWO-NOOP-MP: Running module pass: NoOpModulePass +; CHECK-NESTED-TWO-NOOP-MP: Finished module pass manager +; CHECK-NESTED-TWO-NOOP-MP: Finished module pass manager diff --git a/tools/opt/Passes.cpp b/tools/opt/Passes.cpp index d58acaf1f6d..44b3acee593 100644 --- a/tools/opt/Passes.cpp +++ b/tools/opt/Passes.cpp @@ -51,11 +51,17 @@ static bool parseModulePassPipeline(ModulePassManager &MPM, for (;;) { // Parse nested pass managers by recursing. if (PipelineText.startswith("module(")) { + ModulePassManager NestedMPM; + + // Parse the inner pipeline into the nested manager. PipelineText = PipelineText.substr(strlen("module(")); - if (!parseModulePassPipeline(MPM, PipelineText)) + if (!parseModulePassPipeline(NestedMPM, PipelineText)) return false; assert(!PipelineText.empty() && PipelineText[0] == ')'); PipelineText = PipelineText.substr(1); + + // Now add the nested manager as a module pass. + MPM.addPass(NestedMPM); } else { // Otherwise try to parse a pass name. size_t End = PipelineText.find_first_of(",)");