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

Small fixes #129

Merged
merged 1 commit into from
Oct 5, 2023
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
5 changes: 2 additions & 3 deletions include/klee/Module/KModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ enum KBlockType { Base, Call, Return };
struct KBlock {
KFunction *parent;
llvm::BasicBlock *basicBlock;

unsigned numInstructions;
KInstruction **instructions;

public:
Expand All @@ -76,9 +74,10 @@ struct KBlock {
virtual KBlockType getKBlockType() const { return KBlockType::Base; }
static bool classof(const KBlock *) { return true; }

unsigned getNumInstructions() const noexcept { return basicBlock->size(); }
KInstruction *getFirstInstruction() const noexcept { return instructions[0]; }
KInstruction *getLastInstruction() const noexcept {
return instructions[numInstructions - 1];
return instructions[getNumInstructions() - 1];
}
std::string getLabel() const;
std::string toString() const;
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/Searcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ weight_type TargetedSearcher::getWeight(ExecutionState *es) {
KBlock *kb = es->pc->parent;
KInstruction *ki = es->pc;
weight_type weight;
if (!target->shouldFailOnThisTarget() && kb->numInstructions &&
if (!target->shouldFailOnThisTarget() && kb->getNumInstructions() &&
!isa<KCallBlock>(kb) && kb->getFirstInstruction() != ki &&
states->tryGetWeight(es, weight)) {
return weight;
Expand Down
13 changes: 3 additions & 10 deletions lib/Core/TypeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,13 @@ void TypeManager::initTypesFromGlobals() {
*/
void TypeManager::initTypesFromInstructions() {
for (auto &function : *(parent->module)) {
auto kf = parent->functionMap[&function];

for (auto &BasicBlock : function) {
unsigned numInstructions = kf->blockMap[&BasicBlock]->numInstructions;
KBlock *kb = kf->blockMap[&BasicBlock];

for (unsigned i = 0; i < numInstructions; ++i) {
llvm::Instruction *inst = kb->instructions[i]->inst;

for (auto &inst : BasicBlock) {
/* Register return type */
getWrappedType(inst->getType());
getWrappedType(inst.getType());

/* Register types for arguments */
for (auto opb = inst->op_begin(), ope = inst->op_end(); opb != ope;
for (auto opb = inst.op_begin(), ope = inst.op_end(); opb != ope;
++opb) {
getWrappedType((*opb)->getType());
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Module/KModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ KFunction::KFunction(llvm::Function *_function, KModule *_km,
kb = new KBlock(this, &*bbit, parent, instructionToRegisterMap,
&instructions[n], globalIndexInc);
}
for (unsigned i = 0; i < kb->numInstructions; i++, n++) {
for (unsigned i = 0, ie = kb->getNumInstructions(); i < ie; i++, n++) {
instructionMap[instructions[n]->inst] = instructions[n];
}
blockMap[&*bbit] = kb;
Expand Down Expand Up @@ -639,8 +639,7 @@ KBlock::KBlock(
KFunction *_kfunction, llvm::BasicBlock *block, KModule *km,
const std::unordered_map<Instruction *, unsigned> &instructionToRegisterMap,
KInstruction **instructionsKF, unsigned &globalIndexInc)
: parent(_kfunction), basicBlock(block), numInstructions(0) {
numInstructions += block->size();
: parent(_kfunction), basicBlock(block) {
instructions = instructionsKF;

for (auto &it : *block) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Module/SarifReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ bool Location::isInside(KBlock *block, const Instructions &origInsts) const {
return false;
return startLine <= last->getLine(); // and `first <= line` from above
} else {
for (size_t i = 0; i < block->numInstructions; ++i) {
for (unsigned i = 0, ie = block->getNumInstructions(); i < ie; ++i) {
auto inst = block->instructions[i];
auto opCode = block->instructions[i]->inst->getOpcode();
if (!isa<DbgInfoIntrinsic>(block->instructions[i]->inst) &&
Expand Down
Loading