8000 Fix issue of global representation by LeoneChen · Pull Request #1484 · SVF-tools/SVF · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix issue of global representation #1484

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

Merged
merged 1 commit into from
Jun 14, 2024
Merged

Conversation

LeoneChen
Copy link
Contributor

#1483

This patch is not widely tested, and we need to think more about how to fix the root causes

@@ -97,6 +97,7 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
inline NodeID getObjectNode(const Value* V)
{
V = LLVMUtil::getGlobalRep(V);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Global rep should always be a global. The getObject node can return a null global obj. Why adding this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why I add V = LLVMUtil::getGlobalRep(V); is that val is converted to global representation in collectObj to perform insert on symInfo->objSymMap

void SymbolTableBuilder::collectObj(const Value* val)
{
val = LLVMUtil::getGlobalRep(val);
SymbolTableInfo::ValueToIDMapTy::iterator iter = symInfo->objSymMap.find(
LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val));
if (iter == symInfo->objSymMap.end())
{
SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
// if the object pointed by the pointer is a constant data (e.g., i32 0) or a global constant object (e.g. string)
// then we treat them as one ConstantObj
if (isConstantObjSym(val) && !symInfo->getModelConstants())
{
symInfo->objSymMap.insert(std::make_pair(svfVal, symInfo->constantSymID()));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me give you a case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stack is like this (pictures below may be more vivid), objSymMap is updated in above collectObj
image
image
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I'm not sure whether this fix is accurate or not

@@ -97,6 +97,7 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
inline NodeID getObjectNode(const Value* V)
{
V = LLVMUtil::getGlobalRep(V);
SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is good to put your V = LLVMUtil::getGlobalRep(V); into method getSVFValue

@LeoneChen
Copy link
Contributor Author

Follow your advise, I find we can just modify addGlobalValueMap and getSVFGlobalValue function pair to use global representation.

So I've pushed a new commit

@LeoneChen
Copy link
Contributor Author

Since it influences all usage about global value, does it will cause new problem?

@yuleisui
Copy link
Collaborator

Since it influences all usage about global value, does it will cause new problem?

It looks to be a clean fix for global. Would you test more and larger bcs before I merge this?

@LeoneChen
Copy link
Contributor Author

I agree that more testing is needed and I will report here if I find something new. Does SVF have some unit test cases and integration test cases that can perform the testing?

@yuleisui
Copy link
Collaborator

I agree that more testing is needed and I will report here if I find something new. Does SVF have some unit test cases and integration test cases that can perform the testing?

Your patch has already passed SVF tests in our CI. Would be good for you to test some large bcs and report back so I can merge your pull request

@LeoneChen
Copy link
Contributor Author

ok

@yuleisui yuleisui merged commit e29e860 into SVF-tools:master Jun 14, 2024
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.

2 participants
0