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

SVF Global not found #1483

Open
LeoneChen opened this issue Jun 11, 2024 · 11 comments
Open

SVF Global not found #1483

LeoneChen opened this issue Jun 11, 2024 · 11 comments

Comments

@LeoneChen
Copy link
Contributor

I use https://github.com/SVF-tools/SVF-example to process two *.ll files (in attachment), but get "SVF Global not found"

Inside SVFModule* svfModule = LLVMModuleSet::buildSVFModule(moduleNameVec);

llvmVal may be a global replacement of val,

const Value* llvmVal = LLVMUtil::getGlobalRep(val);
assert(SVFUtil::isa<GlobalValue>(llvmVal) && "not a GlobalValue?");
glob->setDefGlobalForMultipleModule(getSVFGlobalValue(SVFUtil::cast<GlobalValue>(llvmVal)));

and then in getSVFGlobalValue, LLVMConst2SVFConst may not able to find g in itself since LLVMConst2SVFConst only updated on non-replacement value, then reports "SVF Global not found!"

assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");

capsule_manager-43d688dc37a73ece.zip

@yuleisui
Copy link
Collaborator

Any idea to fix this?

@LeoneChen
Copy link
Contributor Author

LeoneChen commented Jun 11, 2024

I don't have a global view of svf project right now, if it's feasible to update the replacement value or other similar solutions while adding per element to LLVMConst2SVFConst?

@yuleisui
Copy link
Collaborator

What is the replacement value? Shall we use this value for global or use the previous one. We will need to map multiple global values to the one actually used?

@LeoneChen
Copy link
Contributor Author

Sorry I mean global replacement usually used in optimization for global value.
https://chatgpt.com/share/2d4cc8ce-9ce4-4b87-afd6-7fcffb4347ad

I'm not sure how to fix it

@LeoneChen
Copy link
Contributor Author

Any idea about this statement const Value* llvmVal = LLVMUtil::getGlobalRep(val);

@yuleisui
Copy link
Collaborator

This is used to get the representation global if we have multiple global symbols referring to the same global variable, so that we could use a unique global to represent all.

looks like we didn’t set the rep global first.

@LeoneChen
Copy link
Contributor Author

Ok I got it, let me test if updating LLVMConst2SVFConst using the representation global works

@yuleisui
Copy link
Collaborator

Thanks

@LeoneChen
Copy link
Contributor Author

I've added a patch to fix the issue I was having, but I don't think this fix the root cause, i.e. it does not fully examine the use of global representation in the whole project.

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()));

@yuleisui
Copy link
Collaborator

Could you make a pull request?

@LeoneChen
Copy link
Contributor Author

PR #1484
Ok, but I'm not sure that it fixes all of these problems

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

No branches or pull requests

2 participants