Skip to content

Commit

Permalink
Merge pull request #992 from ChoKyuWon/master
Browse files Browse the repository at this point in the history
Fix a assertion failure cause i128 type
  • Loading branch information
yuleisui authored Jan 8, 2023
2 parents 9e04b55 + c3c3932 commit 7ecebf5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion svf-llvm/lib/ICFGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ void ICFGBuilder::processFunBody(WorkList& worklist)
/// branch condition value
const ConstantInt* condVal = const_cast<SwitchInst*>(si)->findCaseDest(const_cast<BasicBlock*>(succ->getParent()));
/// default case is set to -1;
s32_t val = condVal ? condVal->getSExtValue() : -1;
s64_t val = -1;
if (condVal && condVal->getBitWidth() <= 64)
val = condVal->getSExtValue();
icfg->addConditionalIntraEdge(srcNode, dstNode, LLVMModuleSet::getLLVMModuleSet()->getSVFValue(si->getCondition()),val);
}
else
Expand Down
4 changes: 3 additions & 1 deletion svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,9 @@ void SVFIRBuilder::visitSwitchInst(SwitchInst &inst)
const Instruction* succInst = &inst.getSuccessor(i)->front();
const ConstantInt* condVal = inst.findCaseDest(inst.getSuccessor(i));
/// default case is set to -1;
s32_t val = condVal ? condVal->getSExtValue() : -1;
s64_t val = -1;
if (condVal && condVal->getBitWidth() <= 64)
val = condVal->getSExtValue();
const SVFInstruction* svfSuccInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(succInst);
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(svfSuccInst);
successors.push_back(std::make_pair(icfgNode,val));
Expand Down
6 changes: 3 additions & 3 deletions svf/include/Graphs/ICFGEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ class IntraCFGEdge : public ICFGEdge
return conditionVar;
}

s32_t getSuccessorCondValue() const
s64_t getSuccessorCondValue() const
{
assert(getCondition() && "this is not a conditional branch edge");
return branchCondVal;
}

void setBranchCondition(const SVFValue* c, s32_t bVal)
void setBranchCondition(const SVFValue* c, s64_t bVal)
{
conditionVar = c;
branchCondVal = bVal;
Expand All @@ -159,7 +159,7 @@ class IntraCFGEdge : public ICFGEdge
/// e.g., Inst1: br %cmp label 0, label 1, Inst2 is label 0 and Inst 3 is label 1;
/// for edge between Inst1 and Inst 2, the first element is %cmp and second element is 0
const SVFValue* conditionVar;
s32_t branchCondVal;
s64_t branchCondVal;
};

/*!
Expand Down
2 changes: 1 addition & 1 deletion svf/include/SVFIR/SVFStatements.h
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ class BranchStmt: public SVFStmt
{
return successors.at(i).first;
}
s32_t getSuccessorCondValue (u32_t i) const
s64_t getSuccessorCondValue (u32_t i) const
{
return successors.at(i).second;
}
Expand Down

0 comments on commit 7ecebf5

Please sign in to comment.