mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
[PM] Fix a bunch of bugs I spotted by inspection when working on this
code. Copious tests added to cover these cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e7687650c9
commit
83bdd1d763
@ -55,6 +55,56 @@
|
||||
; CHECK-MIXED-FP-AND-MP: Running module pass: NoOpModulePass
|
||||
; CHECK-MIXED-FP-AND-MP: Finished module pass manager
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='no-op-module)' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED1
|
||||
; CHECK-UNBALANCED1: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='module(no-op-module))' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED2
|
||||
; CHECK-UNBALANCED2: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='module(no-op-module' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED3
|
||||
; CHECK-UNBALANCED3: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='no-op-function)' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED4
|
||||
; CHECK-UNBALANCED4: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='function(no-op-function))' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED5
|
||||
; CHECK-UNBALANCED5: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='function(function(no-op-function)))' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED6
|
||||
; CHECK-UNBALANCED6: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='function(no-op-function' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED7
|
||||
; CHECK-UNBALANCED7: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='function(function(no-op-function)' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED8
|
||||
; CHECK-UNBALANCED8: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='no-op-module,)' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED9
|
||||
; CHECK-UNBALANCED9: unable to parse pass pipeline description
|
||||
|
||||
; RUN: not opt -disable-output -debug-pass-manager \
|
||||
; RUN: -passes='no-op-function,)' %s 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-UNBALANCED10
|
||||
; CHECK-UNBALANCED10: unable to parse pass pipeline description
|
||||
|
||||
define void @f() {
|
||||
ret void
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ static bool isFunctionPassName(StringRef Name) {
|
||||
}
|
||||
|
||||
static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
|
||||
assert(isModulePassName(Name));
|
||||
if (Name == "no-op-module") {
|
||||
MPM.addPass(NoOpModulePass());
|
||||
return true;
|
||||
@ -59,7 +58,6 @@ static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
|
||||
}
|
||||
|
||||
static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
|
||||
assert(isFunctionPassName(Name));
|
||||
if (Name == "no-op-function") {
|
||||
FPM.addPass(NoOpFunctionPass());
|
||||
return true;
|
||||
@ -76,9 +74,10 @@ static bool parseFunctionPassPipeline(FunctionPassManager &FPM,
|
||||
|
||||
// Parse the inner pipeline inte the nested manager.
|
||||
PipelineText = PipelineText.substr(strlen("function("));
|
||||
if (!parseFunctionPassPipeline(NestedFPM, PipelineText))
|
||||
if (!parseFunctionPassPipeline(NestedFPM, PipelineText) ||
|
||||
PipelineText.empty())
|
||||
return false;
|
||||
assert(!PipelineText.empty() && PipelineText[0] == ')');
|
||||
assert(PipelineText[0] == ')');
|
||||
PipelineText = PipelineText.substr(1);
|
||||
|
||||
// Add the nested pass manager with the appropriate adaptor.
|
||||
@ -109,9 +108,10 @@ static bool parseModulePassPipeline(ModulePassManager &MPM,
|
||||
|
||||
// Parse the inner pipeline into the nested manager.
|
||||
PipelineText = PipelineText.substr(strlen("module("));
|
||||
if (!parseModulePassPipeline(NestedMPM, PipelineText))
|
||||
if (!parseModulePassPipeline(NestedMPM, PipelineText) ||
|
||||
PipelineText.empty())
|
||||
return false;
|
||||
assert(!PipelineText.empty() && PipelineText[0] == ')');
|
||||
assert(PipelineText[0] == ')');
|
||||
PipelineText = PipelineText.substr(1);
|
||||
|
||||
// Now add the nested manager as a module pass.
|
||||
@ -121,9 +121,10 @@ static bool parseModulePassPipeline(ModulePassManager &MPM,
|
||||
|
||||
// Parse the inner pipeline inte the nested manager.
|
||||
PipelineText = PipelineText.substr(strlen("function("));
|
||||
if (!parseFunctionPassPipeline(NestedFPM, PipelineText))
|
||||
if (!parseFunctionPassPipeline(NestedFPM, PipelineText) ||
|
||||
PipelineText.empty())
|
||||
return false;
|
||||
assert(!PipelineText.empty() && PipelineText[0] == ')');
|
||||
assert(PipelineText[0] == ')');
|
||||
PipelineText = PipelineText.substr(1);
|
||||
|
||||
// Add the nested pass manager with the appropriate adaptor.
|
||||
@ -151,23 +152,24 @@ static bool parseModulePassPipeline(ModulePassManager &MPM,
|
||||
bool llvm::parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText) {
|
||||
// Look at the first entry to figure out which layer to start parsing at.
|
||||
if (PipelineText.startswith("module("))
|
||||
return parseModulePassPipeline(MPM, PipelineText);
|
||||
return parseModulePassPipeline(MPM, PipelineText) && PipelineText.empty();
|
||||
if (PipelineText.startswith("function(")) {
|
||||
FunctionPassManager FPM;
|
||||
if (!parseFunctionPassPipeline(FPM, PipelineText))
|
||||
if (!parseFunctionPassPipeline(FPM, PipelineText) || !PipelineText.empty())
|
||||
return false;
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(FPM));
|
||||
return true;
|
||||
}
|
||||
|
||||
// This isn't a direct pass manager name, look for the end of a pass name.
|
||||
StringRef FirstName = PipelineText.substr(0, PipelineText.find_first_of(","));
|
||||
StringRef FirstName =
|
||||
PipelineText.substr(0, PipelineText.find_first_of(",)"));
|
||||
if (isModulePassName(FirstName))
|
||||
return parseModulePassPipeline(MPM, PipelineText);
|
||||
return parseModulePassPipeline(MPM, PipelineText) && PipelineText.empty();
|
||||
|
||||
if (isFunctionPassName(FirstName)) {
|
||||
FunctionPassManager FPM;
|
||||
if (!parseFunctionPassPipeline(FPM, PipelineText))
|
||||
if (!parseFunctionPassPipeline(FPM, PipelineText) || !PipelineText.empty())
|
||||
return false;
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(FPM));
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user