-
Notifications
You must be signed in to change notification settings - Fork 440
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
Conversation
2. add MaxByteLimit Option
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)
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1264 +/- ##
=======================================
Coverage 64.49% 64.49%
=======================================
Files 223 223
Lines 23766 23791 +25
=======================================
+ Hits 15327 15344 +17
- Misses 8439 8447 +8
|
svf/lib/MemoryModel/AccessPath.cpp
Outdated
/// \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]; |
There was a problem hiding this comment.
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);
svf/lib/MemoryModel/AccessPath.cpp
Outdated
return structByteOffset; | ||
} | ||
else | ||
assert(false && "struct type can only pair with constant idx"); |
There was a problem hiding this comment.
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.
svf/lib/MemoryModel/AccessPath.cpp
Outdated
assert(false && "struct type can only pair with constant idx"); | ||
} | ||
else { | ||
assert(false && "gep type pair only support arr/ptr/struct"); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize it.
svf-llvm/lib/SVFIRExtAPI.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't change this.
svf-llvm/lib/SVFIRBuilder.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
svf/include/MemoryModel/AccessPath.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the format back
and remove some meaningless change
also fix some bug in gepStmt.
This PR cannot handle LLVM 15 or higher, that is the Opaque pointer.