Skip to content

Commit

Permalink
Mark mutant record as llvm used to avoid dce
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun authored and AlexDenisov committed May 10, 2021
1 parent a61213a commit 0377f54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/MutationPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>

#include <cassert>
#include <sstream>
Expand Down Expand Up @@ -130,13 +131,18 @@ void MutationPoint::recordMutation() {
std::string encoding = getUserIdentifier() + ':' + std::to_string(isCovered());
llvm::Constant *constant =
llvm::ConstantDataArray::getString(module->getContext(), llvm::StringRef(encoding));
auto *global = new llvm::GlobalVariable(
*module, constant->getType(), true, llvm::GlobalVariable::InternalLinkage, constant);
auto *global = new llvm::GlobalVariable(*module,
constant->getType(),
true,
llvm::GlobalVariable::InternalLinkage,
constant,
this->getUserIdentifier());
#if defined __APPLE__
global->setSection("__mull,.mull_mutants");
#else
global->setSection(".mull_mutants");
#endif
llvm::appendToUsed(*module, {global});
}

std::string MutationPoint::getMutatorIdentifier() const {
Expand Down

0 comments on commit 0377f54

Please sign in to comment.