Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ladisgin committed Sep 29, 2023
1 parent 0a0f1a9 commit b973c6d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 39 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,6 @@ else()
message(STATUS "TCMalloc support disabled")
endif()

# For old valgrind
list(APPEND KLEE_COMPONENT_CXX_FLAGS "-gdwarf-4")

################################################################################
# Detect SQLite3
################################################################################
Expand Down
1 change: 0 additions & 1 deletion lib/Core/ExecutionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ class ExecutionState {
TreeOStream symPathOS;

/// @brief Set containing which lines in which files are covered by this state
// TODO change to StringRef
std::map<std::string, std::set<size_t>> coveredLines;

/// @brief Pointer to the process tree of the current state
Expand Down
47 changes: 21 additions & 26 deletions lib/Core/StatsTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,50 +763,45 @@ void StatsTracker::writeIStats() {

of << "ob=" << llvm::sys::path::filename(objectFilename).str() << "\n";

for (auto &fnIt : *m) {
if (!fnIt.isDeclaration()) {
for (auto &fn : *m) {
if (!fn.isDeclaration()) {
// Always try to write the filename before the function name, as otherwise
// KCachegrind can create two entries for the function, one with an
// unnamed file and one without.
Function *fn = &fnIt;
auto fnl = getLocationInfo(fn);
// const FunctionInfo &ii =
// executor.kmodule->infos->getFunctionInfo(*fn);
if (fnl.file != sourceFile) {
of << "fl=" << fnl.file << "\n";
sourceFile = fnl.file;
auto fnlFile = getLocationInfo(&fn).file;
if (fnlFile != sourceFile) {
of << "fl=" << fnlFile << "\n";
sourceFile = fnlFile;
}

of << "fn=" << fnIt.getName().str() << "\n";
for (Function::iterator bbIt = fnIt.begin(), bb_ie = fnIt.end();
bbIt != bb_ie; ++bbIt) {
for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end();
it != ie; ++it) {
Instruction *instr = &*it;
of << "fn=" << fn.getName().str() << "\n";
for (auto &bb : fn) {
for (auto &instr : bb) {
Instruction *instrPtr = &instr;

auto locationInfo = getLocationInfo(instr);
auto instrLI = getLocationInfo(instrPtr);

unsigned index = executor.kmodule->getGlobalIndex(instr);
if (locationInfo.file != sourceFile) {
of << "fl=" << locationInfo.file << "\n";
sourceFile = locationInfo.file;
unsigned index = executor.kmodule->getGlobalIndex(instrPtr);
if (instrLI.file != sourceFile) {
of << "fl=" << instrLI.file << "\n";
sourceFile = instrLI.file;
}

{
auto asmLine = executor.kmodule->getAsmLine(instr);
auto asmLine = executor.kmodule->getAsmLine(instrPtr);
assert(asmLine.has_value());
of << asmLine.value() << " ";
}

of << locationInfo.line << " ";
of << instrLI.line << " ";
for (unsigned i = 0; i < nStats; i++)
if (istatsMask.test(i))
of << sm.getIndexedValue(sm.getStatistic(i), index) << " ";
of << "\n";

if (UseCallPaths &&
(isa<CallInst>(instr) || isa<InvokeInst>(instr))) {
CallSiteSummaryTable::iterator it = callSiteStats.find(instr);
(isa<CallInst>(instrPtr) || isa<InvokeInst>(instrPtr))) {
CallSiteSummaryTable::iterator it = callSiteStats.find(instrPtr);
if (it != callSiteStats.end()) {
for (auto &fit : it->second) {
const Function *f = fit.first;
Expand All @@ -826,12 +821,12 @@ void StatsTracker::writeIStats() {
of << fli.line << "\n";

{
auto asmLine = executor.kmodule->getAsmLine(instr);
auto asmLine = executor.kmodule->getAsmLine(instrPtr);
assert(asmLine.has_value());
of << asmLine.value() << " ";
}

of << locationInfo.line << " ";
of << instrLI.line << " ";
for (unsigned i = 0; i < nStats; i++) {
if (istatsMask.test(i)) {
Statistic &s = sm.getStatistic(i);
Expand Down
3 changes: 0 additions & 3 deletions lib/Module/KInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ KInstruction::KInstruction(
llvm::Instruction *_inst, KModule *_km, KBlock *_kb,
unsigned &_globalIndexInc)
: inst(_inst), parent(_kb), globalIndex(_globalIndexInc++) {
// ki->parent = this;
// ki->index = i;
// ki->dest = instructionToRegisterMap[inst];
if (isa<llvm::CallInst>(inst) || isa<llvm::InvokeInst>(inst)) {
const llvm::CallBase &cs = cast<llvm::CallBase>(*inst);
Value *val = cs.getCalledOperand();
Expand Down
8 changes: 3 additions & 5 deletions lib/Module/KModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,9 @@ KFunction::KFunction(llvm::Function *_function, KModule *_km,
unsigned n = 0;
// The first arg_size() registers are reserved for formals.
unsigned rnum = getNumArgs();
for (auto &bbit : *function) {
for (auto &it : bbit) {
instructionToRegisterMap[&it] = rnum++;
for (auto &bb : *function) {
for (auto &instr : bb) {
instructionToRegisterMap[&instr] = rnum++;
}
}

Expand Down Expand Up @@ -625,7 +625,6 @@ size_t KFunction::getLine() const {
return locationInfo.line;
}

// TODO problem files with same name
std::string KFunction::getSourceFilepath() const {
auto locationInfo = getLocationInfo(function);
return locationInfo.file;
Expand All @@ -645,7 +644,6 @@ KBlock::KBlock(
numInstructions += block->size();
instructions = instructionsKF;

// size_t i = 0;
for (auto &it : *block) {
KInstruction *ki;

Expand Down
1 change: 0 additions & 1 deletion tools/klee/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,6 @@ int main(int argc, char **argv, char **envp) {
EntryPoint = stubEntryPoint;
}

// change to StringRef
std::set<std::string> mainModuleFunctions;
for (auto &Function : *mainModule) {
if (!Function.isDeclaration()) {
Expand Down

0 comments on commit b973c6d

Please sign in to comment.