-
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
opaque pointer support (type inference) for c #1323
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1323 +/- ##
==========================================
+ Coverage 65.72% 65.96% +0.23%
==========================================
Files 225 227 +2
Lines 24255 24452 +197
==========================================
+ Hits 15942 16130 +188
- Misses 8313 8322 +9
|
svf-llvm/include/SVF-LLVM/LLVMUtil.h
Outdated
|
||
|
||
/// Select the largest (conservative) type from all types | ||
const Type* selectLargestType(std::vector<const Type*>& objTys); |
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.
move to typeinference.
svf-llvm/include/SVF-LLVM/LLVMUtil.h
Outdated
/// Select the largest (conservative) type from all types | ||
const Type* selectLargestType(std::vector<const Type*>& objTys); | ||
|
||
u32_t getArgNoInCallBase(const CallBase* callBase, const Value* arg); |
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.
move to typeinference
svf-llvm/include/SVF-LLVM/LLVMUtil.h
Outdated
@@ -446,9 +455,7 @@ const Value* getVCallVtblPtr(const CallBase* cs); | |||
s32_t getVCallIdx(const CallBase* cs); |
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.
consider moving cpp related methods to cpputil
svf-llvm/include/SVF-LLVM/LLVMUtil.h
Outdated
@@ -446,9 +455,7 @@ const Value* getVCallVtblPtr(const CallBase* cs); | |||
s32_t getVCallIdx(const CallBase* cs); | |||
bool classTyHasVTable(const StructType* ty); | |||
std::string getClassNameFromType(const StructType* ty); | |||
std::string getClassNameOfThisPtr(const CallBase* cs); |
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.
move to cpputil
@@ -82,6 +84,18 @@ class SymbolTableBuilder | |||
void handleCE(const Value* val); | |||
// @} | |||
|
|||
|
|||
std::unique_ptr<TypeInference> & getTypeInference(); |
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.
manual release
std::unique_ptr<TypeInference> & getTypeInference(); | ||
|
||
/// Forward collect all possible infer sites starting from a value | ||
const Type* getOrInferLLVMObjType(const Value *startValue); |
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.
InferObjType
} | ||
|
||
/// get or infer the type of a value | ||
const Type *getOrInferLLVMObjType(const Value *startValue); |
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.
InferObjType
private: | ||
|
||
/// Forward collect all possible infer sites starting from a value | ||
const Type *fwGetOrInferLLVMObjType(const Value *startValue); |
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.
fwInferObjType
const Type *fwGetOrInferLLVMObjType(const Value *startValue); | ||
|
||
/// Backward collect all possible allocation sites (stack, static, heap) starting from a value | ||
Set<const Value *> bwGetOrfindAllocations(const Value *startValue); |
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.
bwInferObjType
svf-llvm/lib/SymbolTableBuilder.cpp
Outdated
@@ -599,7 +650,7 @@ ObjTypeInfo* SymbolTableBuilder::createObjTypeInfo(const Value* val) | |||
} | |||
else | |||
{ | |||
SVFUtil::errs() << dumpValue(val) << "\n"; | |||
SVFUtil::errs() << VALUE_WITH_DBGINFO(val) << "\n"; |
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.
make it a function dumpValueAndDbgInfo
svf/lib/Graphs/CHG.cpp
Outdated
@@ -75,6 +75,8 @@ void CHGraph::addEdge(const string className, const string baseClassName, | |||
{ | |||
CHNode *srcNode = getNode(className); | |||
CHNode *dstNode = getNode(baseClassName); | |||
// cannot self inheritance | |||
if(srcNode == dstNode && edgeType == CHEdge::INHERITANCE) return; |
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.
put it in separate cpp patch
76e7260
to
6a31b42
Compare
Set<const Value *> bwfindAllocations(const Value *startValue); | ||
|
||
/// Determine type based on infer site | ||
static const Type *infersiteToType(const Value *val); |
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.
remove static
/// Determine type based on infer site | ||
static const Type *infersiteToType(const Value *val); | ||
|
||
static bool isAllocation(const Value *val); |
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.
remove static
static const Type *defaultTy(const Value *val); | ||
|
||
/// Opaque pointer type | ||
inline static const Type *defaultPtrTy() { |
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.
remove static
return PointerType::getUnqual(getLLVMCtx()); | ||
} | ||
|
||
inline static LLVMContext &getLLVMCtx() { |
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.
remove static
void typeSizeDiffTest(const PointerType *oPTy, const Type *iTy, const Value *val); | ||
|
||
/// Default type | ||
static const Type *defaultTy(const Value *val); |
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.
remove static
|
||
public: | ||
|
||
explicit TypeInference() = default; |
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.
TypeInference(LLVMContext &)
No description provided.