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

add range limit to IntegerType #1264

Merged
merged 25 commits into from
Dec 2, 2023
Merged

add range limit to IntegerType #1264

merged 25 commits into from
Dec 2, 2023

Conversation

bjjwwang
Copy link
Contributor

@bjjwwang bjjwwang commented Nov 30, 2023

also fix some bug in gepStmt.

This PR cannot handle LLVM 15 or higher, that is the Opaque pointer.

jiawei.wang and others added 17 commits November 24, 2023 23:52
2) add isStaticDeterminedByteSize and getByteSizeOfObj in ObjTypeInfo (with getter/setter) and MemObj(only getter)
3) fulfill SymbolTableBuilder::initTypeInfo() to init the ByteSize related field
2) fix a bug in IntervalValue compare Op
3) remove ConstantOffset bool flag. Instead, if byteSize != 0, it is signal of constant offset. If byteSize = 0, it can be zero byte size or non-const offset.
4) add analyzeHeapAllocByteSize(const Value*), which accepts a CallInst like (malloc/calloc/..) and analyze the allocation byte Size of heap function
5) remove the hard code (99999) of maxByteLimit in SVFIR2ItvExeState::getBytefromGepTypePair, and replace it with Options::MaxFieldLimit()
2) add getByteSize and SetByteSize in SVFType
add rangeLimit to AddrStmt and CopyStmt(bitcast)
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Merging #1264 (204056a) into master (aa07d03) will increase coverage by 0.00%.
Report is 6 commits behind head on master.
The diff coverage is 37.50%.

❗ Current head 204056a differs from pull request most recent head df9b57d. Consider uploading reports for the commit df9b57d to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1264   +/-   ##
=======================================
  Coverage   64.49%   64.49%           
=======================================
  Files         223      223           
  Lines       23766    23791   +25     
=======================================
+ Hits        15327    15344   +17     
- Misses       8439     8447    +8     
Files Coverage Δ
svf-llvm/lib/SVFIRBuilder.cpp 78.20% <100.00%> (+0.04%) ⬆️
svf-llvm/lib/SVFIRExtAPI.cpp 80.14% <100.00%> (+0.14%) ⬆️
svf/include/SVFIR/SVFStatements.h 83.00% <100.00%> (ø)
svf/lib/Graphs/VFG.cpp 48.32% <100.00%> (ø)
svf/lib/SVFIR/SVFFileSystem.cpp 78.73% <100.00%> (ø)
svf/include/MemoryModel/AccessPath.h 83.33% <75.00%> (ø)
svf/lib/MemoryModel/AccessPath.cpp 3.22% <5.00%> (-0.31%) ⬇️

... and 8 files with indirect coverage changes

/// \return Return elem byte size for ptr/arr type
/// Return byte offset from the beginning of the structure to the field where it is located for struct type
u32_t AccessPath::getByteOffsetfromGepTypePair(u32_t gepIdx) const {
IdxVarAndGepTypePair IdxVarAndType = offsetVarAndGepTypePairs[gepIdx];
Copy link
Collaborator

@yuleisui yuleisui Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getSizeOfAggregateElement(SVFVar* idxVar, SVFType* idxType);

return structByteOffset;
}
else
assert(false && "struct type can only pair with constant idx");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct field should always be accessed by a constant idx.

assert(false && "struct type can only pair with constant idx");
}
else {
assert(false && "gep type pair only support arr/ptr/struct");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only support arr/ptr/struct for gep offset.

gep->getIdxOperandVarAndSubTypePairVec()[i].first->getValue();
if (const SVFConstantInt *op = SVFUtil::dyn_cast<SVFConstantInt>(idxValue)) {
s64_t lb = (double)Options::MaxFieldLimit() / elemOrAggregateSize >= op->getSExtValue() ?op->getSExtValue() * elemOrAggregateSize
u32_t elemByteSize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize it.

@@ -67,7 +67,8 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
builder.collectSym(offset);
pag->addValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset));
}
ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change this.

@@ -290,7 +290,8 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
const Value* offsetVal = gi.getOperand();
const SVFValue* offsetSvfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(offsetVal);
assert(gepTy != offsetVal->getType() && "iteration and operand have the same type?");
ap.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(offsetSvfVal)), svfGepTy);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change this. make it untouched.

@@ -151,6 +151,10 @@ class AccessPath
return computeAllLocations().intersects(RHS.computeAllLocations());
}

/// Return elem byte size for ptr/arr type,
/// Return byte offset from the beginning of the structure to the field where it is located for struct type
u32_t getStructAggregateSize(const SVFVar* idxOperandVar, const SVFStructType* idxOperandType) const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is offset not size?

{
const SVFValue *value = gep->getOffsetVarAndGepTypePairVec()[i].first->getValue();
const SVFType *type = gep->getOffsetVarAndGepTypePairVec()[i].second;
const SVFValue *value =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the format back

jiawei.wang added 2 commits December 2, 2023 11:27
@yuleisui yuleisui merged commit eae8d50 into SVF-tools:master Dec 2, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants