svf-tools 1.0.1037 → 1.0.1039
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/Graphs/SCC.h +18 -2
- package/svf/include/SVFIR/SVFIR.h +2 -2
- package/svf/include/SVFIR/SVFValue.h +5 -3
- package/svf/include/SVFIR/SVFVariables.h +2 -3
- package/svf/include/WPA/WPAFSSolver.h +8 -16
- package/svf/lib/MSSA/MemRegion.cpp +4 -5
- package/svf/lib/SVFIR/SVFValue.cpp +1 -3
- package/svf/lib/SVFIR/SVFVariables.cpp +2 -2
- package/svf/lib/WPA/Andersen.cpp +5 -14
- package/svf-llvm/lib/LLVMModule.cpp +6 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +15 -2
- package/svf-llvm/lib/SVFIRExtAPI.cpp +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1039",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/svf/include/Graphs/SCC.h
CHANGED
|
@@ -123,14 +123,30 @@ public:
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
// Return a handle to the stack of nodes in topological
|
|
126
|
-
// order.
|
|
126
|
+
// order. This will be used to seed the initial solution
|
|
127
127
|
// and improve efficiency.
|
|
128
128
|
inline GNodeStack &topoNodeStack()
|
|
129
129
|
{
|
|
130
130
|
return _T;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
/// Return a handle to the stack of nodes in reverse topological
|
|
134
|
+
/// order. This will be used to seed the initial solution
|
|
135
|
+
/// and improve efficiency.
|
|
136
|
+
inline GNodeStack revTopoNodeStack()
|
|
137
|
+
{
|
|
138
|
+
GNodeStack revTopoOrder;
|
|
139
|
+
GNodeStack topoOrder = topoNodeStack();
|
|
140
|
+
while(!topoOrder.empty())
|
|
141
|
+
{
|
|
142
|
+
NodeID nodeID = topoOrder.top();
|
|
143
|
+
topoOrder.pop();
|
|
144
|
+
revTopoOrder.push(nodeID);
|
|
145
|
+
}
|
|
146
|
+
return revTopoOrder;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const inline GNODESCCInfoMap &GNodeSCCInfo() const
|
|
134
150
|
{
|
|
135
151
|
return _NodeSCCAuxInfo;
|
|
136
152
|
}
|
|
@@ -553,10 +553,10 @@ private:
|
|
|
553
553
|
return addValNode(node);
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type
|
|
556
|
+
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type)
|
|
557
557
|
{
|
|
558
558
|
ArgValVar* node =
|
|
559
|
-
new ArgValVar(i, argNo, icfgNode, callGraphNode, type
|
|
559
|
+
new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
|
|
560
560
|
return addValNode(node);
|
|
561
561
|
}
|
|
562
562
|
|
|
@@ -292,6 +292,8 @@ public:
|
|
|
292
292
|
//@}
|
|
293
293
|
};
|
|
294
294
|
|
|
295
|
+
class ArgValVar;
|
|
296
|
+
|
|
295
297
|
class SVFFunction : public SVFValue
|
|
296
298
|
{
|
|
297
299
|
friend class LLVMModuleSet;
|
|
@@ -316,7 +318,7 @@ private:
|
|
|
316
318
|
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
|
|
317
319
|
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
|
|
318
320
|
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
319
|
-
std::vector<const
|
|
321
|
+
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
|
|
320
322
|
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
321
323
|
const CallGraphNode *callGraphNode; /// call graph node for this function
|
|
322
324
|
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
@@ -327,7 +329,7 @@ protected:
|
|
|
327
329
|
callGraphNode = cgn;
|
|
328
330
|
}
|
|
329
331
|
|
|
330
|
-
inline void addArgument(
|
|
332
|
+
inline void addArgument(const ArgValVar* arg)
|
|
331
333
|
{
|
|
332
334
|
allArgs.push_back(arg);
|
|
333
335
|
}
|
|
@@ -417,7 +419,7 @@ public:
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
u32_t arg_size() const;
|
|
420
|
-
const
|
|
422
|
+
const ArgValVar* getArg(u32_t idx) const;
|
|
421
423
|
bool isVarArg() const;
|
|
422
424
|
|
|
423
425
|
inline bool hasBasicBlock() const
|
|
@@ -368,7 +368,6 @@ class ArgValVar: public ValVar
|
|
|
368
368
|
private:
|
|
369
369
|
const CallGraphNode* cgNode;
|
|
370
370
|
u32_t argNo;
|
|
371
|
-
bool uncalled;
|
|
372
371
|
|
|
373
372
|
protected:
|
|
374
373
|
/// Constructor to create function argument (for SVFIRReader/deserialization)
|
|
@@ -401,7 +400,7 @@ public:
|
|
|
401
400
|
|
|
402
401
|
/// Constructor
|
|
403
402
|
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const CallGraphNode* callGraphNode,
|
|
404
|
-
const SVFType* svfType
|
|
403
|
+
const SVFType* svfType);
|
|
405
404
|
|
|
406
405
|
/// Return name of a LLVM value
|
|
407
406
|
inline const std::string getValueName() const
|
|
@@ -422,7 +421,7 @@ public:
|
|
|
422
421
|
|
|
423
422
|
inline bool isArgOfUncalledFunction() const
|
|
424
423
|
{
|
|
425
|
-
return
|
|
424
|
+
return getFunction()->isUncalledFunction();
|
|
426
425
|
}
|
|
427
426
|
|
|
428
427
|
virtual bool isPointer() const;
|
|
@@ -69,31 +69,23 @@ protected:
|
|
|
69
69
|
/// SCC detection
|
|
70
70
|
this->getSCCDetector()->find();
|
|
71
71
|
|
|
72
|
+
assert(nodeStack.empty() && "node stack is not empty, some nodes are not popped properly.");
|
|
73
|
+
|
|
72
74
|
/// Both rep and sub nodes need to be processed later.
|
|
73
75
|
/// Collect sub nodes from SCCDetector.
|
|
74
|
-
NodeStack revTopoStack;
|
|
75
|
-
|
|
76
|
-
while (!topoStack.empty())
|
|
76
|
+
NodeStack revTopoStack = this->getSCCDetector()->revTopoNodeStack();
|
|
77
|
+
while (!revTopoStack.empty())
|
|
77
78
|
{
|
|
78
|
-
NodeID nodeId =
|
|
79
|
-
|
|
79
|
+
NodeID nodeId = revTopoStack.top();
|
|
80
|
+
revTopoStack.pop();
|
|
80
81
|
const NodeBS& subNodes = this->getSCCDetector()->subNodes(nodeId);
|
|
81
82
|
for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it)
|
|
82
83
|
{
|
|
83
|
-
|
|
84
|
+
/// restore the topological order.
|
|
85
|
+
nodeStack.push(*it);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
assert(nodeStack.empty() && "node stack is not empty, some nodes are not popped properly.");
|
|
88
|
-
|
|
89
|
-
/// restore the topological order.
|
|
90
|
-
while (!revTopoStack.empty())
|
|
91
|
-
{
|
|
92
|
-
NodeID nodeId = revTopoStack.top();
|
|
93
|
-
revTopoStack.pop();
|
|
94
|
-
nodeStack.push(nodeId);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
89
|
return nodeStack;
|
|
98
90
|
}
|
|
99
91
|
};
|
|
@@ -461,12 +461,11 @@ bool MRGenerator::addModSideEffectOfCallSite(const CallICFGNode* cs, const NodeB
|
|
|
461
461
|
*/
|
|
462
462
|
void MRGenerator::getCallGraphSCCRevTopoOrder(WorkList& worklist)
|
|
463
463
|
{
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
while(!topoOrder.empty())
|
|
464
|
+
NodeStack revTopoNodeStack = callGraphSCC->revTopoNodeStack();
|
|
465
|
+
while(!revTopoNodeStack.empty())
|
|
467
466
|
{
|
|
468
|
-
NodeID callgraphNodeID =
|
|
469
|
-
|
|
467
|
+
NodeID callgraphNodeID = revTopoNodeStack.top();
|
|
468
|
+
revTopoNodeStack.pop();
|
|
470
469
|
worklist.push(callgraphNodeID);
|
|
471
470
|
}
|
|
472
471
|
}
|
|
@@ -160,8 +160,6 @@ SVFFunction::SVFFunction(const SVFType* ty, const SVFFunctionType* ft,
|
|
|
160
160
|
|
|
161
161
|
SVFFunction::~SVFFunction()
|
|
162
162
|
{
|
|
163
|
-
for(const SVFArgument* arg : allArgs)
|
|
164
|
-
delete arg;
|
|
165
163
|
delete loopAndDom;
|
|
166
164
|
delete bbGraph;
|
|
167
165
|
}
|
|
@@ -171,7 +169,7 @@ u32_t SVFFunction::arg_size() const
|
|
|
171
169
|
return allArgs.size();
|
|
172
170
|
}
|
|
173
171
|
|
|
174
|
-
const
|
|
172
|
+
const ArgValVar* SVFFunction::getArg(u32_t idx) const
|
|
175
173
|
{
|
|
176
174
|
assert (idx < allArgs.size() && "getArg() out of range!");
|
|
177
175
|
return allArgs[idx];
|
|
@@ -102,9 +102,9 @@ const std::string ObjVar::toString() const
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
ArgValVar::ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn,
|
|
105
|
-
const SVF::CallGraphNode* callGraphNode, const SVFType* svfType
|
|
105
|
+
const SVF::CallGraphNode* callGraphNode, const SVFType* svfType)
|
|
106
106
|
: ValVar(i, svfType, icn, ArgValNode),
|
|
107
|
-
cgNode(callGraphNode), argNo(argNo)
|
|
107
|
+
cgNode(callGraphNode), argNo(argNo)
|
|
108
108
|
{
|
|
109
109
|
|
|
110
110
|
}
|
package/svf/lib/WPA/Andersen.cpp
CHANGED
|
@@ -709,25 +709,16 @@ inline void Andersen::collapseFields()
|
|
|
709
709
|
*/
|
|
710
710
|
void Andersen::mergeSccCycle()
|
|
711
711
|
{
|
|
712
|
-
NodeStack revTopoOrder;
|
|
713
|
-
|
|
714
|
-
while (!topoOrder.empty())
|
|
712
|
+
NodeStack revTopoOrder = getSCCDetector()->revTopoNodeStack();
|
|
713
|
+
while (!revTopoOrder.empty())
|
|
715
714
|
{
|
|
716
|
-
NodeID repNodeId =
|
|
717
|
-
|
|
718
|
-
|
|
715
|
+
NodeID repNodeId = revTopoOrder.top();
|
|
716
|
+
revTopoOrder.pop();
|
|
717
|
+
|
|
719
718
|
const NodeBS& subNodes = getSCCDetector()->subNodes(repNodeId);
|
|
720
719
|
// merge sub nodes to rep node
|
|
721
720
|
mergeSccNodes(repNodeId, subNodes);
|
|
722
721
|
}
|
|
723
|
-
|
|
724
|
-
// restore the topological order for later solving.
|
|
725
|
-
while (!revTopoOrder.empty())
|
|
726
|
-
{
|
|
727
|
-
NodeID nodeId = revTopoOrder.top();
|
|
728
|
-
revTopoOrder.pop();
|
|
729
|
-
topoOrder.push(nodeId);
|
|
730
|
-
}
|
|
731
722
|
}
|
|
732
723
|
|
|
733
724
|
|
|
@@ -90,6 +90,12 @@ LLVMModuleSet::~LLVMModuleSet()
|
|
|
90
90
|
delete item.second;
|
|
91
91
|
item.second = nullptr;
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
for (auto& item: LLVMArgument2SVFArgument)
|
|
95
|
+
{
|
|
96
|
+
delete item.second;
|
|
97
|
+
item.second = nullptr;
|
|
98
|
+
}
|
|
93
99
|
delete typeInference;
|
|
94
100
|
typeInference = nullptr;
|
|
95
101
|
}
|
|
@@ -294,7 +300,6 @@ void LLVMModuleSet::createSVFFunction(const Function* func)
|
|
|
294
300
|
if (!arg.hasName())
|
|
295
301
|
svfarg->setName(std::to_string(arg.getArgNo()));
|
|
296
302
|
|
|
297
|
-
svfFunc->addArgument(svfarg);
|
|
298
303
|
addArgumentMap(&arg, svfarg);
|
|
299
304
|
}
|
|
300
305
|
|
|
@@ -228,8 +228,9 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
228
228
|
{
|
|
229
229
|
pag->addArgValNode(
|
|
230
230
|
iter->second, argval->getArgNo(), icfgNode,
|
|
231
|
-
llvmModuleSet()->getCallGraphNode(argval->getParent()),iter->first->getType()
|
|
232
|
-
|
|
231
|
+
llvmModuleSet()->getCallGraphNode(argval->getParent()),iter->first->getType());
|
|
232
|
+
if (!argval->hasName())
|
|
233
|
+
pag->getGNode(iter->second)->setName("arg_" + std::to_string(argval->getArgNo()));
|
|
233
234
|
}
|
|
234
235
|
else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
|
|
235
236
|
{
|
|
@@ -403,6 +404,18 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
403
404
|
assert(pag->getTotalNodeNum() >= pag->getTotalSymNum()
|
|
404
405
|
&& "not all node have been initialized!!!");
|
|
405
406
|
|
|
407
|
+
/// add argvalvar for svffunctions
|
|
408
|
+
for (auto& fun: svfModule->getFunctionSet())
|
|
409
|
+
{
|
|
410
|
+
const Function* llvmFun = SVFUtil::cast<Function>(llvmModuleSet()->getLLVMValue(fun));
|
|
411
|
+
for (const Argument& arg : llvmFun->args())
|
|
412
|
+
{
|
|
413
|
+
const_cast<SVFFunction *>(fun)->addArgument(
|
|
414
|
+
SVFUtil::cast<ArgValVar>(
|
|
415
|
+
pag->getGNode(llvmModuleSet()->getValueNode(llvmModuleSet()->getSVFArgument(&arg)))));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
406
419
|
}
|
|
407
420
|
|
|
408
421
|
/*
|
|
@@ -272,12 +272,12 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
272
272
|
assert((forkedFun->arg_size() <= 2) && "Size of formal parameter of start routine should be one");
|
|
273
273
|
if (forkedFun->arg_size() <= 2 && forkedFun->arg_size() >= 1)
|
|
274
274
|
{
|
|
275
|
-
const
|
|
275
|
+
const ArgValVar* formalParm = forkedFun->getArg(0);
|
|
276
276
|
/// Connect actual parameter to formal parameter of the start routine
|
|
277
277
|
if (actualParm->isPointer() && formalParm->getType()->isPointerTy())
|
|
278
278
|
{
|
|
279
279
|
FunEntryICFGNode *entry = pag->getICFG()->getFunEntryICFGNode(forkedFun);
|
|
280
|
-
addThreadForkEdge(actualParm->getId(),
|
|
280
|
+
addThreadForkEdge(actualParm->getId(), formalParm->getId(), callICFGNode, entry);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|