mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-30 14:50:30 +00:00
[llvm-reduce] Add flag to only run specific passes
Reviewed By: fhahn, hans Differential Revision: https://reviews.llvm.org/D101278
This commit is contained in:
parent
27caabe390
commit
62d0262970
24
test/tools/llvm-reduce/custom-delta-passes.ll
Normal file
24
test/tools/llvm-reduce/custom-delta-passes.ll
Normal file
@ -0,0 +1,24 @@
|
||||
; RUN: llvm-reduce --delta-passes=module-inline-asm --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
|
||||
; RUN: FileCheck --check-prefix=CHECK-NOCHANGE %s < %t
|
||||
; RUN: llvm-reduce --delta-passes=function-bodies --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
|
||||
; RUN: FileCheck --check-prefix=CHECK-CHANGE %s < %t
|
||||
; RUN: llvm-reduce --delta-passes=function-bodies,module-inline-asm --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
|
||||
; RUN: FileCheck --check-prefix=CHECK-CHANGE %s < %t
|
||||
|
||||
; RUN: not llvm-reduce --delta-passes=foo --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2>&1 | FileCheck %s --check-prefix=ERROR
|
||||
; RUN: not llvm-reduce --delta-passes='function-bodies;module-inline-asm' --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2>&1 | FileCheck %s --check-prefix=ERROR
|
||||
|
||||
; RUN: llvm-reduce --print-delta-passes --test FileCheck %s 2>&1 | FileCheck %s --check-prefix=PRINT
|
||||
|
||||
; CHECK-INTERESTINGNESS: @f
|
||||
|
||||
; CHECK-NOCHANGE: define {{.*}} @f
|
||||
; CHECK-CHANGE: declare {{.*}} @f
|
||||
|
||||
; ERROR: unknown
|
||||
|
||||
; PRINT: function-bodies
|
||||
|
||||
define void @f() {
|
||||
ret void
|
||||
}
|
@ -28,25 +28,65 @@
|
||||
#include "deltas/ReduceModuleInlineAsm.h"
|
||||
#include "deltas/ReduceOperandBundles.h"
|
||||
#include "deltas/ReduceSpecialGlobals.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
namespace llvm {
|
||||
using namespace llvm;
|
||||
|
||||
// TODO: Add CLI option to run only specified Passes (for unit tests)
|
||||
void runDeltaPasses(TestRunner &Tester) {
|
||||
reduceSpecialGlobalsDeltaPass(Tester);
|
||||
reduceAliasesDeltaPass(Tester);
|
||||
reduceFunctionBodiesDeltaPass(Tester);
|
||||
reduceFunctionsDeltaPass(Tester);
|
||||
reduceBasicBlocksDeltaPass(Tester);
|
||||
reduceGlobalValuesDeltaPass(Tester);
|
||||
reduceGlobalsInitializersDeltaPass(Tester);
|
||||
reduceGlobalsDeltaPass(Tester);
|
||||
reduceMetadataDeltaPass(Tester);
|
||||
reduceArgumentsDeltaPass(Tester);
|
||||
reduceInstructionsDeltaPass(Tester);
|
||||
reduceOperandBundesDeltaPass(Tester);
|
||||
reduceAttributesDeltaPass(Tester);
|
||||
reduceModuleInlineAsmDeltaPass(Tester);
|
||||
// TODO: Implement the remaining Delta Passes
|
||||
static cl::opt<std::string>
|
||||
DeltaPasses("delta-passes",
|
||||
cl::desc("Delta passes to run, separated by commas. By "
|
||||
"default, run all delta passes."));
|
||||
|
||||
#define DELTA_PASSES \
|
||||
DELTA_PASS("special-globals", reduceSpecialGlobalsDeltaPass) \
|
||||
DELTA_PASS("aliases", reduceAliasesDeltaPass) \
|
||||
DELTA_PASS("function-bodies", reduceFunctionBodiesDeltaPass) \
|
||||
DELTA_PASS("functions", reduceFunctionsDeltaPass) \
|
||||
DELTA_PASS("basic-blocks", reduceBasicBlocksDeltaPass) \
|
||||
DELTA_PASS("global-values", reduceGlobalValuesDeltaPass) \
|
||||
DELTA_PASS("global-initializers", reduceGlobalsInitializersDeltaPass) \
|
||||
DELTA_PASS("global-variables", reduceGlobalsDeltaPass) \
|
||||
DELTA_PASS("metadata", reduceMetadataDeltaPass) \
|
||||
DELTA_PASS("arguments", reduceArgumentsDeltaPass) \
|
||||
DELTA_PASS("instructions", reduceInstructionsDeltaPass) \
|
||||
DELTA_PASS("operand-bundles", reduceOperandBundesDeltaPass) \
|
||||
DELTA_PASS("attributes", reduceAttributesDeltaPass) \
|
||||
DELTA_PASS("module-inline-asm", reduceModuleInlineAsmDeltaPass)
|
||||
|
||||
static void runAllDeltaPasses(TestRunner &Tester) {
|
||||
#define DELTA_PASS(NAME, FUNC) FUNC(Tester);
|
||||
DELTA_PASSES
|
||||
#undef DELTA_PASS
|
||||
}
|
||||
|
||||
static void runDeltaPassName(TestRunner &Tester, StringRef PassName) {
|
||||
#define DELTA_PASS(NAME, FUNC) \
|
||||
if (PassName == NAME) { \
|
||||
FUNC(Tester); \
|
||||
return; \
|
||||
}
|
||||
DELTA_PASSES
|
||||
#undef DELTA_PASS
|
||||
errs() << "unknown pass \"" << PassName << "\"";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void llvm::printDeltaPasses(raw_ostream &OS) {
|
||||
OS << "Delta passes (pass to `--delta-passes=` as a comma separated list):\n";
|
||||
#define DELTA_PASS(NAME, FUNC) OS << " " << NAME << "\n";
|
||||
DELTA_PASSES
|
||||
#undef DELTA_PASS
|
||||
}
|
||||
|
||||
void llvm::runDeltaPasses(TestRunner &Tester) {
|
||||
if (DeltaPasses.empty()) {
|
||||
runAllDeltaPasses(Tester);
|
||||
} else {
|
||||
StringRef Passes = DeltaPasses;
|
||||
while (!Passes.empty()) {
|
||||
auto Split = Passes.split(",");
|
||||
runDeltaPassName(Tester, Split.first);
|
||||
Passes = Split.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace llvm
|
||||
|
@ -14,9 +14,11 @@
|
||||
#ifndef LLVM_TOOLS_LLVM_REDUCE_DELTAMANAGER_H
|
||||
#define LLVM_TOOLS_LLVM_REDUCE_DELTAMANAGER_H
|
||||
|
||||
#include "TestRunner.h"
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
class TestRunner;
|
||||
|
||||
void printDeltaPasses(raw_ostream &OS);
|
||||
void runDeltaPasses(TestRunner &Tester);
|
||||
} // namespace llvm
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "DeltaManager.h"
|
||||
#include "TestRunner.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
@ -35,6 +36,11 @@ static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden,
|
||||
static cl::opt<bool> Version("v", cl::desc("Alias for -version"), cl::Hidden,
|
||||
cl::cat(Options));
|
||||
|
||||
static cl::opt<bool>
|
||||
PrintDeltaPasses("print-delta-passes",
|
||||
cl::desc("Print list of delta passes, passable to "
|
||||
"--delta-passes as a comma separated list"));
|
||||
|
||||
static cl::opt<std::string> InputFilename(cl::Positional, cl::Required,
|
||||
cl::desc("<input llvm ll/bc file>"),
|
||||
cl::cat(Options));
|
||||
@ -101,6 +107,11 @@ int main(int Argc, char **Argv) {
|
||||
|
||||
cl::ParseCommandLineOptions(Argc, Argv, "LLVM automatic testcase reducer.\n");
|
||||
|
||||
if (PrintDeltaPasses) {
|
||||
printDeltaPasses(errs());
|
||||
return 0;
|
||||
}
|
||||
|
||||
LLVMContext Context;
|
||||
std::unique_ptr<Module> OriginalProgram =
|
||||
parseInputFile(InputFilename, Context);
|
||||
|
Loading…
Reference in New Issue
Block a user