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

opaque pointer support (type inference) for c #1323

Merged
merged 77 commits into from
Jan 25, 2024

Conversation

jumormt
Copy link
Contributor

@jumormt jumormt commented Jan 16, 2024

No description provided.

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (4f2f3da) 65.72% compared to head (d620c42) 65.96%.

Additional details and impacted files

Impacted file tree graph

@@            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     
Files Coverage Δ
svf-llvm/include/SVF-LLVM/LLVMModule.h 97.87% <ø> (-0.03%) ⬇️
svf-llvm/include/SVF-LLVM/LLVMUtil.h 75.00% <ø> (ø)
svf-llvm/include/SVF-LLVM/ObjTypeInference.h 100.00% <100.00%> (ø)
svf-llvm/include/SVF-LLVM/SVFIRBuilder.h 90.00% <100.00%> (ø)
svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h 100.00% <ø> (ø)
svf-llvm/lib/CHGBuilder.cpp 86.08% <ø> (ø)
svf-llvm/lib/SVFIRBuilder.cpp 79.07% <100.00%> (-0.30%) ⬇️
svf-llvm/lib/SVFIRExtAPI.cpp 79.85% <100.00%> (-0.30%) ⬇️
svf-llvm/tools/CFL/cfl.cpp 93.75% <ø> (ø)
svf-llvm/tools/Example/svf-ex.cpp 36.66% <ø> (ø)
... and 11 more

... and 1 file with indirect coverage changes



/// Select the largest (conservative) type from all types
const Type* selectLargestType(std::vector<const Type*>& objTys);
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to typeinference.

/// 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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to typeinference

@@ -446,9 +455,7 @@ const Value* getVCallVtblPtr(const CallBase* cs);
s32_t getVCallIdx(const CallBase* cs);
Copy link
Collaborator

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

@@ -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);
Copy link
Collaborator

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();
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

bwInferObjType

@@ -599,7 +650,7 @@ ObjTypeInfo* SymbolTableBuilder::createObjTypeInfo(const Value* val)
}
else
{
SVFUtil::errs() << dumpValue(val) << "\n";
SVFUtil::errs() << VALUE_WITH_DBGINFO(val) << "\n";
Copy link
Collaborator

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

@@ -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;
Copy link
Collaborator

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

@jumormt jumormt force-pushed the opaque-c branch 2 times, most recently from 76e7260 to 6a31b42 Compare January 21, 2024 05:22
Set<const Value *> bwfindAllocations(const Value *startValue);

/// Determine type based on infer site
static const Type *infersiteToType(const Value *val);
Copy link
Collaborator

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);
Copy link
Collaborator

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() {
Copy link
Collaborator

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() {
Copy link
Collaborator

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);
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

TypeInference(LLVMContext &)

@jumormt jumormt marked this pull request as ready for review January 24, 2024 03:56
@yuleisui yuleisui merged commit 6bf9865 into SVF-tools:master Jan 25, 2024
5 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