mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
finegrainify namespacification
llvm-svn: 10839
This commit is contained in:
parent
7cba50960d
commit
98f2200fb2
@ -22,7 +22,6 @@
|
|||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/FileUtilities.h"
|
#include "Support/FileUtilities.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
// Anonymous namespace to define command line options for debugging.
|
// Anonymous namespace to define command line options for debugging.
|
||||||
@ -38,12 +37,10 @@ namespace {
|
|||||||
"(for miscompilation detection)"));
|
"(for miscompilation detection)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
/// getPassesString - Turn a list of passes into a string which indicates the
|
/// getPassesString - Turn a list of passes into a string which indicates the
|
||||||
/// command line options that must be passed to add the passes.
|
/// command line options that must be passed to add the passes.
|
||||||
///
|
///
|
||||||
std::string getPassesString(const std::vector<const PassInfo*> &Passes) {
|
std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
|
||||||
std::string Result;
|
std::string Result;
|
||||||
for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
|
||||||
if (i) Result += " ";
|
if (i) Result += " ";
|
||||||
@ -56,7 +53,7 @@ std::string getPassesString(const std::vector<const PassInfo*> &Passes) {
|
|||||||
// DeleteFunctionBody - "Remove" the function by deleting all of its basic
|
// DeleteFunctionBody - "Remove" the function by deleting all of its basic
|
||||||
// blocks, making it external.
|
// blocks, making it external.
|
||||||
//
|
//
|
||||||
void DeleteFunctionBody(Function *F) {
|
void llvm::DeleteFunctionBody(Function *F) {
|
||||||
// delete the body of the function...
|
// delete the body of the function...
|
||||||
F->deleteBody();
|
F->deleteBody();
|
||||||
assert(F->isExternal() && "This didn't make the function external!");
|
assert(F->isExternal() && "This didn't make the function external!");
|
||||||
@ -184,4 +181,3 @@ void BugDriver::PrintFunctionList(const std::vector<Function*> &Funcs) {
|
|||||||
std::cout << std::flush;
|
std::cout << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@ -32,29 +32,29 @@
|
|||||||
#include "Support/FileUtilities.h"
|
#include "Support/FileUtilities.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
extern cl::list<std::string> InputArgv;
|
||||||
|
|
||||||
extern cl::list<std::string> InputArgv;
|
class ReduceMisCodegenFunctions : public ListReducer<Function*> {
|
||||||
|
BugDriver &BD;
|
||||||
class ReduceMisCodegenFunctions : public ListReducer<Function*> {
|
public:
|
||||||
BugDriver &BD;
|
ReduceMisCodegenFunctions(BugDriver &bd) : BD(bd) {}
|
||||||
public:
|
|
||||||
ReduceMisCodegenFunctions(BugDriver &bd) : BD(bd) {}
|
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
||||||
|
std::vector<Function*> &Suffix) {
|
||||||
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
if (!Prefix.empty() && TestFuncs(Prefix))
|
||||||
std::vector<Function*> &Suffix) {
|
return KeepPrefix;
|
||||||
if (!Prefix.empty() && TestFuncs(Prefix))
|
if (!Suffix.empty() && TestFuncs(Suffix))
|
||||||
return KeepPrefix;
|
return KeepSuffix;
|
||||||
if (!Suffix.empty() && TestFuncs(Suffix))
|
return NoFailure;
|
||||||
return KeepSuffix;
|
}
|
||||||
return NoFailure;
|
|
||||||
}
|
bool TestFuncs(const std::vector<Function*> &CodegenTest,
|
||||||
|
bool KeepFiles = false);
|
||||||
bool TestFuncs(const std::vector<Function*> &CodegenTest,
|
};
|
||||||
bool KeepFiles = false);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
||||||
bool KeepFiles) {
|
bool KeepFiles) {
|
||||||
@ -328,7 +328,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisambiguateGlobalSymbols(Module *M) {
|
static void DisambiguateGlobalSymbols(Module *M) {
|
||||||
// First, try not to cause collisions by minimizing chances of renaming an
|
// First, try not to cause collisions by minimizing chances of renaming an
|
||||||
// already-external symbol, so take in external globals and functions as-is.
|
// already-external symbol, so take in external globals and functions as-is.
|
||||||
Disambiguator D;
|
Disambiguator D;
|
||||||
@ -406,5 +406,3 @@ bool BugDriver::debugCodeGenerator() {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@ -28,21 +28,22 @@
|
|||||||
#include "Support/FileUtilities.h"
|
#include "Support/FileUtilities.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class DebugCrashes : public ListReducer<const PassInfo*> {
|
||||||
class DebugCrashes : public ListReducer<const PassInfo*> {
|
BugDriver &BD;
|
||||||
BugDriver &BD;
|
public:
|
||||||
public:
|
DebugCrashes(BugDriver &bd) : BD(bd) {}
|
||||||
DebugCrashes(BugDriver &bd) : BD(bd) {}
|
|
||||||
|
// doTest - Return true iff running the "removed" passes succeeds, and
|
||||||
// doTest - Return true iff running the "removed" passes succeeds, and running
|
// running the "Kept" passes fail when run on the output of the "removed"
|
||||||
// the "Kept" passes fail when run on the output of the "removed" passes. If
|
// passes. If we return true, we update the current module of bugpoint.
|
||||||
// we return true, we update the current module of bugpoint.
|
//
|
||||||
//
|
virtual TestResult doTest(std::vector<const PassInfo*> &Removed,
|
||||||
virtual TestResult doTest(std::vector<const PassInfo*> &Removed,
|
std::vector<const PassInfo*> &Kept);
|
||||||
std::vector<const PassInfo*> &Kept);
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
DebugCrashes::TestResult
|
DebugCrashes::TestResult
|
||||||
DebugCrashes::doTest(std::vector<const PassInfo*> &Prefix,
|
DebugCrashes::doTest(std::vector<const PassInfo*> &Prefix,
|
||||||
@ -82,22 +83,24 @@ DebugCrashes::doTest(std::vector<const PassInfo*> &Prefix,
|
|||||||
return NoFailure;
|
return NoFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReduceCrashingFunctions : public ListReducer<Function*> {
|
namespace llvm {
|
||||||
BugDriver &BD;
|
class ReduceCrashingFunctions : public ListReducer<Function*> {
|
||||||
public:
|
BugDriver &BD;
|
||||||
ReduceCrashingFunctions(BugDriver &bd) : BD(bd) {}
|
public:
|
||||||
|
ReduceCrashingFunctions(BugDriver &bd) : BD(bd) {}
|
||||||
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
|
||||||
std::vector<Function*> &Kept) {
|
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
||||||
if (!Kept.empty() && TestFuncs(Kept))
|
std::vector<Function*> &Kept) {
|
||||||
return KeepSuffix;
|
if (!Kept.empty() && TestFuncs(Kept))
|
||||||
if (!Prefix.empty() && TestFuncs(Prefix))
|
return KeepSuffix;
|
||||||
return KeepPrefix;
|
if (!Prefix.empty() && TestFuncs(Prefix))
|
||||||
return NoFailure;
|
return KeepPrefix;
|
||||||
}
|
return NoFailure;
|
||||||
|
}
|
||||||
bool TestFuncs(std::vector<Function*> &Prefix);
|
|
||||||
};
|
bool TestFuncs(std::vector<Function*> &Prefix);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
|
bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
|
||||||
// Clone the program to try hacking it apart...
|
// Clone the program to try hacking it apart...
|
||||||
@ -143,27 +146,29 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// ReduceCrashingBlocks reducer - This works by setting the terminators of all
|
namespace llvm {
|
||||||
/// terminators except the specified basic blocks to a 'ret' instruction, then
|
/// ReduceCrashingBlocks reducer - This works by setting the terminators of
|
||||||
/// running the simplify-cfg pass. This has the effect of chopping up the CFG
|
/// all terminators except the specified basic blocks to a 'ret' instruction,
|
||||||
/// really fast which can reduce large functions quickly.
|
/// then running the simplify-cfg pass. This has the effect of chopping up
|
||||||
///
|
/// the CFG really fast which can reduce large functions quickly.
|
||||||
class ReduceCrashingBlocks : public ListReducer<BasicBlock*> {
|
///
|
||||||
BugDriver &BD;
|
class ReduceCrashingBlocks : public ListReducer<BasicBlock*> {
|
||||||
public:
|
BugDriver &BD;
|
||||||
ReduceCrashingBlocks(BugDriver &bd) : BD(bd) {}
|
public:
|
||||||
|
ReduceCrashingBlocks(BugDriver &bd) : BD(bd) {}
|
||||||
|
|
||||||
virtual TestResult doTest(std::vector<BasicBlock*> &Prefix,
|
virtual TestResult doTest(std::vector<BasicBlock*> &Prefix,
|
||||||
std::vector<BasicBlock*> &Kept) {
|
std::vector<BasicBlock*> &Kept) {
|
||||||
if (!Kept.empty() && TestBlocks(Kept))
|
if (!Kept.empty() && TestBlocks(Kept))
|
||||||
return KeepSuffix;
|
return KeepSuffix;
|
||||||
if (!Prefix.empty() && TestBlocks(Prefix))
|
if (!Prefix.empty() && TestBlocks(Prefix))
|
||||||
return KeepPrefix;
|
return KeepPrefix;
|
||||||
return NoFailure;
|
return NoFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestBlocks(std::vector<BasicBlock*> &Prefix);
|
bool TestBlocks(std::vector<BasicBlock*> &Prefix);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool ReduceCrashingBlocks::TestBlocks(std::vector<BasicBlock*> &BBs) {
|
bool ReduceCrashingBlocks::TestBlocks(std::vector<BasicBlock*> &BBs) {
|
||||||
// Clone the program to try hacking it apart...
|
// Clone the program to try hacking it apart...
|
||||||
@ -403,4 +408,3 @@ bool BugDriver::debugCrash() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@ -29,7 +29,6 @@ BUGPOINT NOTES:
|
|||||||
#include "llvm/Support/ToolRunner.h"
|
#include "llvm/Support/ToolRunner.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -61,12 +60,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
// Anything specified after the --args option are taken as arguments to the
|
||||||
// Anything specified after the --args option are taken as arguments to the
|
// program being debugged.
|
||||||
// program being debugged.
|
cl::list<std::string>
|
||||||
cl::list<std::string>
|
InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
|
||||||
InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
|
cl::ZeroOrMore);
|
||||||
cl::ZeroOrMore);
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// BugDriver method implementation
|
// BugDriver method implementation
|
||||||
@ -237,4 +236,3 @@ bool BugDriver::isExecutingJIT() {
|
|||||||
return InterpreterSel == RunJIT;
|
return InterpreterSel == RunJIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@ -18,17 +18,19 @@
|
|||||||
#include "llvm/Transforms/Utils/Cloning.h"
|
#include "llvm/Transforms/Utils/Cloning.h"
|
||||||
#include "llvm/Transforms/Utils/Linker.h"
|
#include "llvm/Transforms/Utils/Linker.h"
|
||||||
#include "Support/FileUtilities.h"
|
#include "Support/FileUtilities.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class ReduceMiscompilingPasses : public ListReducer<const PassInfo*> {
|
class ReduceMiscompilingPasses : public ListReducer<const PassInfo*> {
|
||||||
BugDriver &BD;
|
BugDriver &BD;
|
||||||
public:
|
public:
|
||||||
ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
|
ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
|
||||||
|
|
||||||
virtual TestResult doTest(std::vector<const PassInfo*> &Prefix,
|
virtual TestResult doTest(std::vector<const PassInfo*> &Prefix,
|
||||||
std::vector<const PassInfo*> &Suffix);
|
std::vector<const PassInfo*> &Suffix);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ReduceMiscompilingPasses::TestResult
|
ReduceMiscompilingPasses::TestResult
|
||||||
ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
||||||
@ -122,22 +124,24 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
|||||||
return NoFailure;
|
return NoFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReduceMiscompilingFunctions : public ListReducer<Function*> {
|
namespace llvm {
|
||||||
BugDriver &BD;
|
class ReduceMiscompilingFunctions : public ListReducer<Function*> {
|
||||||
public:
|
BugDriver &BD;
|
||||||
ReduceMiscompilingFunctions(BugDriver &bd) : BD(bd) {}
|
public:
|
||||||
|
ReduceMiscompilingFunctions(BugDriver &bd) : BD(bd) {}
|
||||||
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
|
||||||
std::vector<Function*> &Suffix) {
|
virtual TestResult doTest(std::vector<Function*> &Prefix,
|
||||||
if (!Suffix.empty() && TestFuncs(Suffix, false))
|
std::vector<Function*> &Suffix) {
|
||||||
return KeepSuffix;
|
if (!Suffix.empty() && TestFuncs(Suffix, false))
|
||||||
if (!Prefix.empty() && TestFuncs(Prefix, false))
|
return KeepSuffix;
|
||||||
return KeepPrefix;
|
if (!Prefix.empty() && TestFuncs(Prefix, false))
|
||||||
return NoFailure;
|
return KeepPrefix;
|
||||||
}
|
return NoFailure;
|
||||||
|
}
|
||||||
bool TestFuncs(const std::vector<Function*> &Prefix, bool EmitBytecode);
|
|
||||||
};
|
bool TestFuncs(const std::vector<Function*> &Prefix, bool EmitBytecode);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
||||||
bool EmitBytecode) {
|
bool EmitBytecode) {
|
||||||
@ -315,4 +319,3 @@ bool BugDriver::debugMiscompilation() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
using namespace llvm;
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
/// writeProgramToFile - This writes the current "Program" to the named bytecode
|
/// writeProgramToFile - This writes the current "Program" to the named bytecode
|
||||||
/// file. If an error occurs, true is returned.
|
/// file. If an error occurs, true is returned.
|
||||||
@ -162,4 +161,3 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
|||||||
return !ExitedOK;
|
return !ExitedOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user