SVF-tools / SVF

Static Value-Flow Analysis Framework for Source Code
http://svf-tools.github.io/SVF/
Other
1.4k stars 437 forks source link

Failed when using `getLLVMValue()` on Value got from `IntraICFGNode->getInst()` #1441

Open S-Hang23 opened 5 months ago

S-Hang23 commented 5 months ago

Hello everyone, I'm new to SVF. I attempted to traverse on ICFG and transfer SVFValue to LLVMValue so that I could do some customed analysis. However, after I get SVFInstruction from IntraICFGNode, and use LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(), This assert failed and shut down the program.

assert(it!=SVFValue2LLVMValue.end() && "can't find corresponding llvm value!")

Some of my code is as follow:

IntraICFGNode* iNode = cast<IntraICFGNode>(icfgNode);
const SVFInstruction* svfInst = iNode->getInst();
if(svfInst == nullptr) continue;
const llvm::Value* llvmVal = LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(svfInst);

I doubt that the svfInst I got from IntraICFGNode could not be found corresponding llvm value. BUT, when I traverse the bitcode like:

for(auto f: *svfModule){
    for(auto bb: *f){
        for(auto i: *bb){
            const llvm::Value* llvmVal = LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(i);
        }
    }
}

The program above worked well. I wonder why both codes convert SVFInstruction into LLVMValue but only second one succeed. Is it not supposed that I use getLLVMValue on SVFInstruction got from IntraICFGNode->getInst()?

yuleisui commented 4 months ago

Could you print out and call the toString() method of that SVFValue or SVFInstruction, so that we know where the issue is?