Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce IR frontend #938

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ add_subdirectory(vendor)
set (MULL_DEFINITIONS ${LLVM_DEFINITIONS})
set (THIRD_PARTY_INCLUDE_DIRS
${LLVM_INCLUDE_DIRS}
${CLANG_INCLUDE_DIRS}
${CMAKE_CURRENT_LIST_DIR}/vendor/LibEBC/lib/include
${CMAKE_CURRENT_LIST_DIR}/vendor/libirm/include
${CMAKE_SOURCE_DIR}/vendor
Expand Down
5 changes: 3 additions & 2 deletions include/mull/Bitcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Diagnostics;

class Bitcode {
public:
explicit Bitcode(std::unique_ptr<llvm::LLVMContext> context,
std::unique_ptr<llvm::Module> module);
explicit Bitcode(llvm::Module *unownedModule);
Bitcode(std::unique_ptr<llvm::LLVMContext> context, std::unique_ptr<llvm::Module> module);

llvm::Module *getModule();
llvm::Module *getModule() const;
Expand All @@ -32,6 +32,7 @@ class Bitcode {
private:
std::unique_ptr<llvm::LLVMContext> context;
std::unique_ptr<llvm::Module> module;
llvm::Module *unownedModule;
std::string uniqueIdentifier;

std::map<llvm::Function *, std::vector<MutationPoint *>> mutationPoints;
Expand Down
12 changes: 11 additions & 1 deletion include/mull/Config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ struct Configuration {
bool keepExecutable;
bool mutateOnly;
bool lowerBitcode;
bool junkDetectionDisabled;

unsigned timeout;
unsigned linkerTimeout;

IDEDiagnosticsKind diagnostics;

std::vector<std::string> bitcodePaths;
std::vector<std::string> bitcodePaths; // TODO: Drop this one
std::vector<std::string> mutators;

std::string executable;
Expand All @@ -39,8 +40,17 @@ struct Configuration {
std::string linker;
std::vector<std::string> linkerFlags;

std::string compilationDatabasePath;
std::vector<std::string> compilerFlags;

std::vector<std::string> includePaths;
std::vector<std::string> excludePaths;

ParallelizationConfig parallelization;

std::string gitDiffRef;
std::string gitProjectRoot;

Configuration();

static std::string findConfig(Diagnostics &diagnostics);
Expand Down
2 changes: 2 additions & 0 deletions include/mull/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ class Driver {
std::vector<FunctionUnderTest> getFunctionsUnderTest();
};

void mutateBitcode(llvm::Module &module);

} // namespace mull
4 changes: 2 additions & 2 deletions include/mull/MutationsFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ namespace mull {

struct Configuration;
class Program;
class ReachableFunction;
class Diagnostics;
class Bitcode;

class MutationsFinder {
public:
MutationsFinder(std::vector<std::unique_ptr<Mutator>> mutators, const Configuration &config);
std::vector<MutationPoint *> getMutationPoints(Diagnostics &diagnostics, const Program &program,
std::vector<MutationPoint *> getMutationPoints(Diagnostics &diagnostics,
std::vector<FunctionUnderTest> &functions);

private:
Expand Down
16 changes: 13 additions & 3 deletions lib/Bitcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,27 @@ using namespace mull;
using namespace llvm;
using namespace std;

Bitcode::Bitcode(llvm::Module *unownedModule)
: context(nullptr), module(nullptr), unownedModule(unownedModule),
uniqueIdentifier(llvm::sys::path::stem(this->unownedModule->getModuleIdentifier()).str()) {}

Bitcode::Bitcode(std::unique_ptr<llvm::LLVMContext> context, std::unique_ptr<llvm::Module> module)
: context(std::move(context)), module(std::move(module)),
: context(std::move(context)), module(std::move(module)), unownedModule(nullptr),
uniqueIdentifier(llvm::sys::path::stem(this->module->getModuleIdentifier()).str()) {}

llvm::Module *Bitcode::getModule() {
assert(module);
assert(module || unownedModule);
if (unownedModule) {
return unownedModule;
}
return module.get();
}

llvm::Module *Bitcode::getModule() const {
assert(module);
assert(module || unownedModule);
if (unownedModule) {
return unownedModule;
}
return module.get();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Config/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ unsigned MullDefaultLinkerTimeoutMilliseconds = 30000;
Configuration::Configuration()
: debugEnabled(false), dryRunEnabled(false), captureTestOutput(true), captureMutantOutput(true),
skipSanityCheckRun(false), includeNotCovered(false), keepObjectFiles(false),
keepExecutable(false), mutateOnly(false), lowerBitcode(false),
keepExecutable(false), mutateOnly(false), lowerBitcode(false), junkDetectionDisabled(false),
timeout(MullDefaultTimeoutMilliseconds), linkerTimeout(MullDefaultLinkerTimeoutMilliseconds),
diagnostics(IDEDiagnosticsKind::None), parallelization(singleThreadParallelization()) {}

Expand Down
10 changes: 10 additions & 0 deletions lib/Config/ConfigurationParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ template <> struct llvm::yaml::MappingTraits<Configuration> {
io.mapOptional("linker", config.linker);
io.mapOptional("linkerFlags", config.linkerFlags);
io.mapOptional("parallelization", config.parallelization);
io.mapOptional("compilationDatabasePath", config.compilationDatabasePath);
io.mapOptional("compilerFlags", config.compilerFlags);
io.mapOptional("junkDetectionDisabled", config.junkDetectionDisabled);
io.mapOptional("gitDiffRef", config.gitDiffRef);
io.mapOptional("gitProjectRoot", config.gitProjectRoot);
io.mapOptional("includePaths", config.includePaths);
io.mapOptional("excludePaths", config.excludePaths);
}
};

std::string Configuration::findConfig(Diagnostics &diagnostics) {
if (getenv("MULL_CONFIG") != nullptr) {
return getenv("MULL_CONFIG");
}
llvm::SmallString<PATH_MAX> cwd;
std::error_code ec = llvm::sys::fs::current_path(cwd);
if (ec) {
Expand Down
Loading