Skip to content

Commit

Permalink
Introduce IR frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDenisov committed Jan 11, 2022
1 parent 9d76d3a commit 44bc993
Show file tree
Hide file tree
Showing 223 changed files with 1,469 additions and 419 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: macos-11
strategy:
matrix:
LLVM_VERSION: ["8.0", "9.0", "11.0", "12.0", "13.0"]
LLVM_VERSION: ["9.0", "11.0", "12.0", "13.0"]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ubuntu-18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
container: ubuntu:18.04
strategy:
matrix:
LLVM_VERSION: ["8.0", "9.0", "10.0"]
LLVM_VERSION: ["9.0", "10.0"]

steps:
- name: For debugging
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ubuntu-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
container: ubuntu:20.04
strategy:
matrix:
LLVM_VERSION: ["8.0", "9.0", "10.0", "11.0", "12.0"]
LLVM_VERSION: ["9.0", "10.0", "11.0", "12.0"]

steps:
- name: Install software
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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 @@ -14,17 +14,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

0 comments on commit 44bc993

Please sign in to comment.