svf-tools 1.0.993 → 1.0.995
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/CDG.h +18 -1
- package/svf/include/Graphs/CFLGraph.h +19 -1
- package/svf/include/Graphs/CHG.h +19 -1
- package/svf/include/Graphs/CallGraph.h +19 -1
- package/svf/include/Graphs/ConsGNode.h +19 -1
- package/svf/include/Graphs/GenericGraph.h +243 -17
- package/svf/include/Graphs/ICFG.h +0 -96
- package/svf/include/Graphs/ICFGNode.h +55 -22
- package/svf/include/Graphs/SVFG.h +2 -2
- package/svf/include/Graphs/SVFGNode.h +5 -17
- package/svf/include/Graphs/SVFGOPT.h +2 -1
- package/svf/include/Graphs/ThreadCallGraph.h +5 -4
- package/svf/include/Graphs/VFG.h +2 -2
- package/svf/include/Graphs/VFGNode.h +99 -26
- package/svf/include/MTA/TCT.h +19 -1
- package/svf/include/MemoryModel/PointerAnalysis.h +1 -1
- package/svf/include/MemoryModel/PointerAnalysisImpl.h +4 -0
- package/svf/include/SABER/SaberCondAllocator.h +2 -2
- package/svf/include/SVFIR/SVFFileSystem.h +1 -1
- package/svf/include/SVFIR/SVFIR.h +2 -2
- package/svf/include/SVFIR/SVFVariables.h +68 -38
- package/svf/include/SVFIR/SymbolTableInfo.h +11 -1
- package/svf/include/Util/SVFUtil.h +1 -1
- package/svf/include/Util/ThreadAPI.h +8 -2
- package/svf/include/WPA/Andersen.h +26 -13
- package/svf/include/WPA/Steensgaard.h +10 -20
- package/svf/include/WPA/TypeAnalysis.h +10 -3
- package/svf/lib/AE/Svfexe/AEDetector.cpp +4 -2
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +10 -12
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +2 -0
- package/svf/lib/DDA/ContextDDA.cpp +12 -8
- package/svf/lib/Graphs/ICFG.cpp +9 -93
- package/svf/lib/Graphs/SVFG.cpp +1 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +10 -2
- package/svf/lib/Graphs/VFG.cpp +2 -4
- package/svf/lib/MSSA/MemRegion.cpp +2 -2
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +37 -0
- package/svf/lib/SABER/LeakChecker.cpp +1 -2
- package/svf/lib/SABER/SaberCondAllocator.cpp +13 -16
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +2 -2
- package/svf/lib/SVFIR/SVFFileSystem.cpp +0 -6
- package/svf/lib/SVFIR/SVFVariables.cpp +3 -0
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +3 -2
- package/svf/lib/Util/ThreadAPI.cpp +15 -5
- package/svf/lib/WPA/Andersen.cpp +205 -151
- package/svf/lib/WPA/Steensgaard.cpp +1 -163
- package/svf-llvm/include/SVF-LLVM/DCHG.h +1 -1
- package/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +93 -23
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +84 -0
- package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +15 -0
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +19 -12
- package/svf-llvm/lib/ICFGBuilder.cpp +125 -54
- package/svf-llvm/lib/LLVMLoopAnalysis.cpp +6 -11
- package/svf-llvm/lib/LLVMModule.cpp +54 -0
- package/svf-llvm/lib/LLVMUtil.cpp +15 -0
- package/svf-llvm/lib/SVFIRBuilder.cpp +92 -76
- package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -5
- package/svf-llvm/lib/SymbolTableBuilder.cpp +4 -4
|
@@ -646,6 +646,21 @@ bool LLVMUtil::isHeapAllocExtCallViaArg(const Instruction* inst)
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
bool LLVMUtil::isNonInstricCallSite(const Instruction* inst)
|
|
650
|
+
{
|
|
651
|
+
SVFInstruction* svfINst =
|
|
652
|
+
LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(inst);
|
|
653
|
+
bool res = SVFUtil::isNonInstricCallSite(svfINst);
|
|
654
|
+
bool res2 = false;
|
|
655
|
+
|
|
656
|
+
if(isIntrinsicInst(inst))
|
|
657
|
+
res2 = false;
|
|
658
|
+
else
|
|
659
|
+
res2 = isCallSite(inst);
|
|
660
|
+
assert(res == res2);
|
|
661
|
+
return res2;
|
|
662
|
+
}
|
|
663
|
+
|
|
649
664
|
namespace SVF
|
|
650
665
|
{
|
|
651
666
|
|
|
@@ -62,9 +62,23 @@ SVFIR* SVFIRBuilder::build()
|
|
|
62
62
|
// Build ICFG
|
|
63
63
|
ICFG* icfg = new ICFG();
|
|
64
64
|
ICFGBuilder icfgbuilder(icfg);
|
|
65
|
-
icfgbuilder.build(
|
|
65
|
+
icfgbuilder.build();
|
|
66
66
|
pag->setICFG(icfg);
|
|
67
67
|
|
|
68
|
+
// Set icfgnode in memobj
|
|
69
|
+
for (auto& it : SymbolTableInfo::SymbolInfo()->idToObjMap())
|
|
70
|
+
{
|
|
71
|
+
if(!it.second->getValue())
|
|
72
|
+
continue;
|
|
73
|
+
if (const Instruction* inst =
|
|
74
|
+
SVFUtil::dyn_cast<Instruction>(llvmModuleSet()->getLLVMValue(
|
|
75
|
+
it.second->getValue())))
|
|
76
|
+
{
|
|
77
|
+
if(llvmModuleSet()->hasICFGNode(inst))
|
|
78
|
+
it.second->gNode = llvmModuleSet()->getICFGNode(inst);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
CHGraph* chg = new CHGraph(pag->getModule());
|
|
69
83
|
CHGBuilder chgbuilder(chg);
|
|
70
84
|
chgbuilder.buildCHG();
|
|
@@ -90,12 +104,12 @@ SVFIR* SVFIRBuilder::build()
|
|
|
90
104
|
///// collect exception vals in the program
|
|
91
105
|
|
|
92
106
|
/// handle functions
|
|
93
|
-
for (Module& M :
|
|
107
|
+
for (Module& M : llvmModuleSet()->getLLVMModules())
|
|
94
108
|
{
|
|
95
109
|
for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
|
|
96
110
|
{
|
|
97
111
|
const Function& fun = *F;
|
|
98
|
-
const SVFFunction* svffun =
|
|
112
|
+
const SVFFunction* svffun = llvmModuleSet()->getSVFFunction(&fun);
|
|
99
113
|
/// collect return node of function fun
|
|
100
114
|
if(!fun.isDeclaration())
|
|
101
115
|
{
|
|
@@ -117,7 +131,7 @@ SVFIR* SVFIRBuilder::build()
|
|
|
117
131
|
I != E; ++I)
|
|
118
132
|
{
|
|
119
133
|
setCurrentLocation(&*I,&fun.getEntryBlock());
|
|
120
|
-
NodeID argValNodeId = pag->getValueNode(
|
|
134
|
+
NodeID argValNodeId = pag->getValueNode(llvmModuleSet()->getSVFValue(&*I));
|
|
121
135
|
// if this is the function does not have caller (e.g. main)
|
|
122
136
|
// or a dead function, shall we create a black hole address edge for it?
|
|
123
137
|
// it is (1) too conservative, and (2) make FormalParmVFGNode defined at blackhole address PAGEdge.
|
|
@@ -200,7 +214,17 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
200
214
|
DBOUT(DPAGBuild, outs() << "add val node " << iter->second << "\n");
|
|
201
215
|
if(iter->second == symTable->blkPtrSymID() || iter->second == symTable->nullPtrSymID())
|
|
202
216
|
continue;
|
|
203
|
-
|
|
217
|
+
|
|
218
|
+
const SVFBaseNode* gNode = nullptr;
|
|
219
|
+
if (const Instruction* inst =
|
|
220
|
+
SVFUtil::dyn_cast<Instruction>(llvmModuleSet()->getLLVMValue(iter->first)))
|
|
221
|
+
{
|
|
222
|
+
if (llvmModuleSet()->hasICFGNode(inst))
|
|
223
|
+
{
|
|
224
|
+
gNode = llvmModuleSet()->getICFGNode(inst);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
pag->addValNode(iter->first, iter->second, gNode);
|
|
204
228
|
}
|
|
205
229
|
|
|
206
230
|
for (SymbolTableInfo::ValueToIDMapTy::iterator iter =
|
|
@@ -276,7 +300,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
|
|
|
276
300
|
assert(V);
|
|
277
301
|
|
|
278
302
|
const llvm::GEPOperator *gepOp = SVFUtil::dyn_cast<const llvm::GEPOperator>(V);
|
|
279
|
-
DataLayout * dataLayout = getDataLayout(
|
|
303
|
+
DataLayout * dataLayout = getDataLayout(llvmModuleSet()->getMainLLVMModule());
|
|
280
304
|
llvm::APInt byteOffset(dataLayout->getIndexSizeInBits(gepOp->getPointerAddressSpace()),0,true);
|
|
281
305
|
if(gepOp && dataLayout && gepOp->accumulateConstantOffset(*dataLayout,byteOffset))
|
|
282
306
|
{
|
|
@@ -290,13 +314,13 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
|
|
|
290
314
|
gi != ge; ++gi)
|
|
291
315
|
{
|
|
292
316
|
const Type* gepTy = *gi;
|
|
293
|
-
const SVFType* svfGepTy =
|
|
317
|
+
const SVFType* svfGepTy = llvmModuleSet()->getSVFType(gepTy);
|
|
294
318
|
|
|
295
319
|
assert((prevPtrOperand && svfGepTy->isPointerTy()) == false &&
|
|
296
320
|
"Expect no more than one gep operand to be of a pointer type");
|
|
297
321
|
if(!prevPtrOperand && svfGepTy->isPointerTy()) prevPtrOperand = true;
|
|
298
322
|
const Value* offsetVal = gi.getOperand();
|
|
299
|
-
const SVFValue* offsetSvfVal =
|
|
323
|
+
const SVFValue* offsetSvfVal = llvmModuleSet()->getSVFValue(offsetVal);
|
|
300
324
|
assert(gepTy != offsetVal->getType() && "iteration and operand have the same type?");
|
|
301
325
|
ap.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(offsetSvfVal)), svfGepTy);
|
|
302
326
|
|
|
@@ -310,7 +334,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
|
|
|
310
334
|
if(!op || (arrTy->getArrayNumElements() <= (u32_t)op->getSExtValue()))
|
|
311
335
|
continue;
|
|
312
336
|
APOffset idx = op->getSExtValue();
|
|
313
|
-
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(
|
|
337
|
+
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(arrTy), idx);
|
|
314
338
|
ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
|
|
315
339
|
}
|
|
316
340
|
else if (const StructType *ST = SVFUtil::dyn_cast<StructType>(gepTy))
|
|
@@ -318,7 +342,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
|
|
|
318
342
|
assert(op && "non-const offset accessing a struct");
|
|
319
343
|
//The actual index
|
|
320
344
|
APOffset idx = op->getSExtValue();
|
|
321
|
-
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(
|
|
345
|
+
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(ST), idx);
|
|
322
346
|
ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
|
|
323
347
|
}
|
|
324
348
|
else if (gepTy->isSingleValueType())
|
|
@@ -351,13 +375,13 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
351
375
|
{
|
|
352
376
|
if (const ConstantExpr* gepce = isGepConstantExpr(ref))
|
|
353
377
|
{
|
|
354
|
-
DBOUT(DPAGBuild, outs() << "handle gep constant expression " <<
|
|
378
|
+
DBOUT(DPAGBuild, outs() << "handle gep constant expression " << llvmModuleSet()->getSVFValue(ref)->toString() << "\n");
|
|
355
379
|
const Constant* opnd = gepce->getOperand(0);
|
|
356
380
|
// handle recursive constant express case (gep (bitcast (gep X 1)) 1)
|
|
357
381
|
processCE(opnd);
|
|
358
382
|
auto &GEPOp = llvm::cast<llvm::GEPOperator>(*gepce);
|
|
359
383
|
Type *pType = GEPOp.getSourceElementType();
|
|
360
|
-
AccessPath ap(0,
|
|
384
|
+
AccessPath ap(0, llvmModuleSet()->getSVFType(pType));
|
|
361
385
|
bool constGep = computeGepOffset(gepce, ap);
|
|
362
386
|
// must invoke pag methods here, otherwise it will be a dead recursion cycle
|
|
363
387
|
const SVFValue* cval = getCurrentValue();
|
|
@@ -367,23 +391,23 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
367
391
|
* The gep edge created are like constexpr (same edge may appear at multiple callsites)
|
|
368
392
|
* so bb/inst of this edge may be rewritten several times, we treat it as global here.
|
|
369
393
|
*/
|
|
370
|
-
addGepEdge(pag->getValueNode(
|
|
394
|
+
addGepEdge(pag->getValueNode(llvmModuleSet()->getSVFValue(opnd)), pag->getValueNode(llvmModuleSet()->getSVFValue(gepce)), ap, constGep);
|
|
371
395
|
setCurrentLocation(cval, cbb);
|
|
372
396
|
}
|
|
373
397
|
else if (const ConstantExpr* castce = isCastConstantExpr(ref))
|
|
374
398
|
{
|
|
375
|
-
DBOUT(DPAGBuild, outs() << "handle cast constant expression " <<
|
|
399
|
+
DBOUT(DPAGBuild, outs() << "handle cast constant expression " << llvmModuleSet()->getSVFValue(ref)->toString() << "\n");
|
|
376
400
|
const Constant* opnd = castce->getOperand(0);
|
|
377
401
|
processCE(opnd);
|
|
378
402
|
const SVFValue* cval = getCurrentValue();
|
|
379
403
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
380
404
|
setCurrentLocation(castce, nullptr);
|
|
381
|
-
addCopyEdge(pag->getValueNode(
|
|
405
|
+
addCopyEdge(pag->getValueNode(llvmModuleSet()->getSVFValue(opnd)), pag->getValueNode(llvmModuleSet()->getSVFValue(castce)), CopyStmt::BITCAST);
|
|
382
406
|
setCurrentLocation(cval, cbb);
|
|
383
407
|
}
|
|
384
408
|
else if (const ConstantExpr* selectce = isSelectConstantExpr(ref))
|
|
385
409
|
{
|
|
386
|
-
DBOUT(DPAGBuild, outs() << "handle select constant expression " <<
|
|
410
|
+
DBOUT(DPAGBuild, outs() << "handle select constant expression " << llvmModuleSet()->getSVFValue(ref)->toString() << "\n");
|
|
387
411
|
const Constant* src1 = selectce->getOperand(1);
|
|
388
412
|
const Constant* src2 = selectce->getOperand(2);
|
|
389
413
|
processCE(src1);
|
|
@@ -391,10 +415,10 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
391
415
|
const SVFValue* cval = getCurrentValue();
|
|
392
416
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
393
417
|
setCurrentLocation(selectce, nullptr);
|
|
394
|
-
NodeID cond = pag->getValueNode(
|
|
395
|
-
NodeID nsrc1 = pag->getValueNode(
|
|
396
|
-
NodeID nsrc2 = pag->getValueNode(
|
|
397
|
-
NodeID nres = pag->getValueNode(
|
|
418
|
+
NodeID cond = pag->getValueNode(llvmModuleSet()->getSVFValue(selectce->getOperand(0)));
|
|
419
|
+
NodeID nsrc1 = pag->getValueNode(llvmModuleSet()->getSVFValue(src1));
|
|
420
|
+
NodeID nsrc2 = pag->getValueNode(llvmModuleSet()->getSVFValue(src2));
|
|
421
|
+
NodeID nres = pag->getValueNode(llvmModuleSet()->getSVFValue(selectce));
|
|
398
422
|
addSelectStmt(nres,nsrc1, nsrc2, cond);
|
|
399
423
|
setCurrentLocation(cval, cbb);
|
|
400
424
|
}
|
|
@@ -406,7 +430,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
406
430
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
407
431
|
const SVFValue* cval = getCurrentValue();
|
|
408
432
|
setCurrentLocation(int2Ptrce, nullptr);
|
|
409
|
-
addCopyEdge(pag->getValueNode(
|
|
433
|
+
addCopyEdge(pag->getValueNode(llvmModuleSet()->getSVFValue(opnd)), pag->getValueNode(llvmModuleSet()->getSVFValue(int2Ptrce)), CopyStmt::INTTOPTR);
|
|
410
434
|
setCurrentLocation(cval, cbb);
|
|
411
435
|
}
|
|
412
436
|
else if (const ConstantExpr* ptr2Intce = isPtr2IntConstantExpr(ref))
|
|
@@ -416,7 +440,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
416
440
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
417
441
|
const SVFValue* cval = getCurrentValue();
|
|
418
442
|
setCurrentLocation(ptr2Intce, nullptr);
|
|
419
|
-
addCopyEdge(pag->getValueNode(
|
|
443
|
+
addCopyEdge(pag->getValueNode(llvmModuleSet()->getSVFValue(opnd)), pag->getValueNode(llvmModuleSet()->getSVFValue(ptr2Intce)), CopyStmt::PTRTOINT);
|
|
420
444
|
setCurrentLocation(cval, cbb);
|
|
421
445
|
}
|
|
422
446
|
else if(isTruncConstantExpr(ref) || isCmpConstantExpr(ref))
|
|
@@ -425,7 +449,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
425
449
|
const SVFValue* cval = getCurrentValue();
|
|
426
450
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
427
451
|
setCurrentLocation(ref, nullptr);
|
|
428
|
-
NodeID dst = pag->getValueNode(
|
|
452
|
+
NodeID dst = pag->getValueNode(llvmModuleSet()->getSVFValue(ref));
|
|
429
453
|
addBlackHoleAddrEdge(dst);
|
|
430
454
|
setCurrentLocation(cval, cbb);
|
|
431
455
|
}
|
|
@@ -435,7 +459,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
435
459
|
const SVFValue* cval = getCurrentValue();
|
|
436
460
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
437
461
|
setCurrentLocation(ref, nullptr);
|
|
438
|
-
NodeID dst = pag->getValueNode(
|
|
462
|
+
NodeID dst = pag->getValueNode(llvmModuleSet()->getSVFValue(ref));
|
|
439
463
|
addBlackHoleAddrEdge(dst);
|
|
440
464
|
setCurrentLocation(cval, cbb);
|
|
441
465
|
}
|
|
@@ -445,7 +469,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
445
469
|
const SVFValue* cval = getCurrentValue();
|
|
446
470
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
447
471
|
setCurrentLocation(ref, nullptr);
|
|
448
|
-
NodeID dst = pag->getValueNode(
|
|
472
|
+
NodeID dst = pag->getValueNode(llvmModuleSet()->getSVFValue(ref));
|
|
449
473
|
addBlackHoleAddrEdge(dst);
|
|
450
474
|
setCurrentLocation(cval, cbb);
|
|
451
475
|
}
|
|
@@ -460,7 +484,7 @@ void SVFIRBuilder::processCE(const Value* val)
|
|
|
460
484
|
const SVFValue* cval = getCurrentValue();
|
|
461
485
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
462
486
|
setCurrentLocation(ref, nullptr);
|
|
463
|
-
NodeID dst = pag->getValueNode(
|
|
487
|
+
NodeID dst = pag->getValueNode(llvmModuleSet()->getSVFValue(ref));
|
|
464
488
|
addAddrEdge(pag->getConstantNode(), dst);
|
|
465
489
|
setCurrentLocation(cval, cbb);
|
|
466
490
|
}
|
|
@@ -506,13 +530,13 @@ NodeID SVFIRBuilder::getGlobalVarField(const GlobalVariable *gvar, u32_t offset,
|
|
|
506
530
|
void SVFIRBuilder::InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
507
531
|
u32_t offset)
|
|
508
532
|
{
|
|
509
|
-
DBOUT(DPAGBuild, outs() << "global " <<
|
|
533
|
+
DBOUT(DPAGBuild, outs() << "global " << llvmModuleSet()->getSVFValue(gvar)->toString() << " constant initializer: " << llvmModuleSet()->getSVFValue(C)->toString() << "\n");
|
|
510
534
|
if (C->getType()->isSingleValueType())
|
|
511
535
|
{
|
|
512
536
|
NodeID src = getValueNode(C);
|
|
513
537
|
// get the field value if it is available, otherwise we create a dummy field node.
|
|
514
538
|
setCurrentLocation(gvar, nullptr);
|
|
515
|
-
NodeID field = getGlobalVarField(gvar, offset,
|
|
539
|
+
NodeID field = getGlobalVarField(gvar, offset, llvmModuleSet()->getSVFType(C->getType()));
|
|
516
540
|
|
|
517
541
|
if (SVFUtil::isa<GlobalVariable, Function>(C))
|
|
518
542
|
{
|
|
@@ -549,7 +573,7 @@ void SVFIRBuilder::InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
|
549
573
|
return;
|
|
550
574
|
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
551
575
|
{
|
|
552
|
-
u32_t off = pag->getSymbolInfo()->getFlattenedElemIdx(
|
|
576
|
+
u32_t off = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(C->getType()), i);
|
|
553
577
|
InitialGlobal(gvar, SVFUtil::cast<Constant>(C->getOperand(i)), offset + off);
|
|
554
578
|
}
|
|
555
579
|
}
|
|
@@ -561,7 +585,7 @@ void SVFIRBuilder::InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
|
561
585
|
{
|
|
562
586
|
for(u32_t i = 0; i < seq->getNumElements(); i++)
|
|
563
587
|
{
|
|
564
|
-
u32_t off = pag->getSymbolInfo()->getFlattenedElemIdx(
|
|
588
|
+
u32_t off = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(C->getType()), i);
|
|
565
589
|
Constant* ct = seq->getElementAsConstant(i);
|
|
566
590
|
InitialGlobal(gvar, ct, offset + off);
|
|
567
591
|
}
|
|
@@ -585,7 +609,7 @@ void SVFIRBuilder::visitGlobal(SVFModule* svfModule)
|
|
|
585
609
|
{
|
|
586
610
|
|
|
587
611
|
/// initialize global variable
|
|
588
|
-
for (Module &M :
|
|
612
|
+
for (Module &M : llvmModuleSet()->getLLVMModules())
|
|
589
613
|
{
|
|
590
614
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
|
|
591
615
|
{
|
|
@@ -599,7 +623,7 @@ void SVFIRBuilder::visitGlobal(SVFModule* svfModule)
|
|
|
599
623
|
if (gvar->hasInitializer())
|
|
600
624
|
{
|
|
601
625
|
Constant *C = gvar->getInitializer();
|
|
602
|
-
DBOUT(DPAGBuild, outs() << "add global var node " <<
|
|
626
|
+
DBOUT(DPAGBuild, outs() << "add global var node " << llvmModuleSet()->getSVFValue(gvar)->toString() << "\n");
|
|
603
627
|
InitialGlobal(gvar, C, 0);
|
|
604
628
|
}
|
|
605
629
|
}
|
|
@@ -621,8 +645,8 @@ void SVFIRBuilder::visitGlobal(SVFModule* svfModule)
|
|
|
621
645
|
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E; I++)
|
|
622
646
|
{
|
|
623
647
|
const GlobalAlias* alias = &*I;
|
|
624
|
-
NodeID dst = pag->getValueNode(
|
|
625
|
-
NodeID src = pag->getValueNode(
|
|
648
|
+
NodeID dst = pag->getValueNode(llvmModuleSet()->getSVFValue(alias));
|
|
649
|
+
NodeID src = pag->getValueNode(llvmModuleSet()->getSVFValue(alias->getAliasee()));
|
|
626
650
|
processCE(alias->getAliasee());
|
|
627
651
|
setCurrentLocation(alias, nullptr);
|
|
628
652
|
addCopyEdge(src, dst, CopyStmt::COPYVAL);
|
|
@@ -640,7 +664,7 @@ void SVFIRBuilder::visitAllocaInst(AllocaInst &inst)
|
|
|
640
664
|
// AllocaInst should always be a pointer type
|
|
641
665
|
assert(SVFUtil::isa<PointerType>(inst.getType()));
|
|
642
666
|
|
|
643
|
-
DBOUT(DPAGBuild, outs() << "process alloca " <<
|
|
667
|
+
DBOUT(DPAGBuild, outs() << "process alloca " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
644
668
|
NodeID dst = getValueNode(&inst);
|
|
645
669
|
|
|
646
670
|
NodeID src = getObjectNode(&inst);
|
|
@@ -655,7 +679,7 @@ void SVFIRBuilder::visitAllocaInst(AllocaInst &inst)
|
|
|
655
679
|
void SVFIRBuilder::visitPHINode(PHINode &inst)
|
|
656
680
|
{
|
|
657
681
|
|
|
658
|
-
DBOUT(DPAGBuild, outs() << "process phi " <<
|
|
682
|
+
DBOUT(DPAGBuild, outs() << "process phi " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
659
683
|
|
|
660
684
|
NodeID dst = getValueNode(&inst);
|
|
661
685
|
|
|
@@ -668,8 +692,7 @@ void SVFIRBuilder::visitPHINode(PHINode &inst)
|
|
|
668
692
|
(void) matched; // Suppress warning of unused variable under release build
|
|
669
693
|
assert(matched && "incomingInst's Function incorrect");
|
|
670
694
|
const Instruction* predInst = &inst.getIncomingBlock(i)->back();
|
|
671
|
-
const
|
|
672
|
-
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(svfPrevInst);
|
|
695
|
+
const ICFGNode* icfgNode = llvmModuleSet()->getICFGNode(predInst);
|
|
673
696
|
NodeID src = getValueNode(val);
|
|
674
697
|
addPhiStmt(dst,src,icfgNode);
|
|
675
698
|
}
|
|
@@ -680,7 +703,7 @@ void SVFIRBuilder::visitPHINode(PHINode &inst)
|
|
|
680
703
|
*/
|
|
681
704
|
void SVFIRBuilder::visitLoadInst(LoadInst &inst)
|
|
682
705
|
{
|
|
683
|
-
DBOUT(DPAGBuild, outs() << "process load " <<
|
|
706
|
+
DBOUT(DPAGBuild, outs() << "process load " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
684
707
|
|
|
685
708
|
NodeID dst = getValueNode(&inst);
|
|
686
709
|
|
|
@@ -697,7 +720,7 @@ void SVFIRBuilder::visitStoreInst(StoreInst &inst)
|
|
|
697
720
|
// StoreInst itself should always not be a pointer type
|
|
698
721
|
assert(!SVFUtil::isa<PointerType>(inst.getType()));
|
|
699
722
|
|
|
700
|
-
DBOUT(DPAGBuild, outs() << "process store " <<
|
|
723
|
+
DBOUT(DPAGBuild, outs() << "process store " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
701
724
|
|
|
702
725
|
NodeID dst = getValueNode(inst.getPointerOperand());
|
|
703
726
|
|
|
@@ -724,11 +747,11 @@ void SVFIRBuilder::visitGetElementPtrInst(GetElementPtrInst &inst)
|
|
|
724
747
|
|
|
725
748
|
assert(SVFUtil::isa<PointerType>(inst.getType()));
|
|
726
749
|
|
|
727
|
-
DBOUT(DPAGBuild, outs() << "process gep " <<
|
|
750
|
+
DBOUT(DPAGBuild, outs() << "process gep " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
728
751
|
|
|
729
752
|
NodeID src = getValueNode(inst.getPointerOperand());
|
|
730
753
|
|
|
731
|
-
AccessPath ap(0,
|
|
754
|
+
AccessPath ap(0, llvmModuleSet()->getSVFType(inst.getSourceElementType()));
|
|
732
755
|
bool constGep = computeGepOffset(&inst, ap);
|
|
733
756
|
addGepEdge(src, dst, ap, constGep);
|
|
734
757
|
}
|
|
@@ -739,7 +762,7 @@ void SVFIRBuilder::visitGetElementPtrInst(GetElementPtrInst &inst)
|
|
|
739
762
|
void SVFIRBuilder::visitCastInst(CastInst &inst)
|
|
740
763
|
{
|
|
741
764
|
|
|
742
|
-
DBOUT(DPAGBuild, outs() << "process cast " <<
|
|
765
|
+
DBOUT(DPAGBuild, outs() << "process cast " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
743
766
|
NodeID dst = getValueNode(&inst);
|
|
744
767
|
|
|
745
768
|
const Value* opnd = inst.getOperand(0);
|
|
@@ -797,7 +820,7 @@ void SVFIRBuilder::visitCmpInst(CmpInst &inst)
|
|
|
797
820
|
void SVFIRBuilder::visitSelectInst(SelectInst &inst)
|
|
798
821
|
{
|
|
799
822
|
|
|
800
|
-
DBOUT(DPAGBuild, outs() << "process select " <<
|
|
823
|
+
DBOUT(DPAGBuild, outs() << "process select " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
801
824
|
|
|
802
825
|
NodeID dst = getValueNode(&inst);
|
|
803
826
|
NodeID src1 = getValueNode(inst.getTrueValue());
|
|
@@ -832,13 +855,12 @@ void SVFIRBuilder::visitCallSite(CallBase* cs)
|
|
|
832
855
|
if(isIntrinsicInst(cs))
|
|
833
856
|
return;
|
|
834
857
|
|
|
835
|
-
const SVFInstruction* svfcall = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
|
|
836
|
-
|
|
837
858
|
DBOUT(DPAGBuild,
|
|
838
859
|
outs() << "process callsite " << svfcall->toString() << "\n");
|
|
839
860
|
|
|
840
|
-
|
|
841
|
-
|
|
861
|
+
|
|
862
|
+
CallICFGNode* callBlockNode = llvmModuleSet()->getCallICFGNode(cs);
|
|
863
|
+
RetICFGNode* retBlockNode = llvmModuleSet()->getRetICFGNode(cs);
|
|
842
864
|
|
|
843
865
|
pag->addCallSite(callBlockNode);
|
|
844
866
|
|
|
@@ -851,7 +873,7 @@ void SVFIRBuilder::visitCallSite(CallBase* cs)
|
|
|
851
873
|
|
|
852
874
|
if (const Function *callee = LLVMUtil::getCallee(cs))
|
|
853
875
|
{
|
|
854
|
-
const SVFFunction* svfcallee =
|
|
876
|
+
const SVFFunction* svfcallee = llvmModuleSet()->getSVFFunction(callee);
|
|
855
877
|
if (isExtCall(svfcallee))
|
|
856
878
|
{
|
|
857
879
|
handleExtCall(cs, svfcallee);
|
|
@@ -877,16 +899,15 @@ void SVFIRBuilder::visitReturnInst(ReturnInst &inst)
|
|
|
877
899
|
// ReturnInst itself should always not be a pointer type
|
|
878
900
|
assert(!SVFUtil::isa<PointerType>(inst.getType()));
|
|
879
901
|
|
|
880
|
-
DBOUT(DPAGBuild, outs() << "process return " <<
|
|
902
|
+
DBOUT(DPAGBuild, outs() << "process return " << llvmModuleSet()->getSVFValue(&inst)->toString() << " \n");
|
|
881
903
|
|
|
882
904
|
if(Value* src = inst.getReturnValue())
|
|
883
905
|
{
|
|
884
|
-
const SVFFunction *F =
|
|
906
|
+
const SVFFunction *F = llvmModuleSet()->getSVFFunction(inst.getParent()->getParent());
|
|
885
907
|
|
|
886
908
|
NodeID rnF = getReturnNode(F);
|
|
887
909
|
NodeID vnS = getValueNode(src);
|
|
888
|
-
const
|
|
889
|
-
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(svfInst);
|
|
910
|
+
const ICFGNode* icfgNode = llvmModuleSet()->getICFGNode(&inst);
|
|
890
911
|
//vnS may be null if src is a null ptr
|
|
891
912
|
addPhiStmt(rnF,vnS,icfgNode);
|
|
892
913
|
}
|
|
@@ -943,8 +964,7 @@ void SVFIRBuilder::visitBranchInst(BranchInst &inst)
|
|
|
943
964
|
for (const Instruction* succInst : nextInsts)
|
|
944
965
|
{
|
|
945
966
|
assert(branchID <= 1 && "if/else has more than two branches?");
|
|
946
|
-
const
|
|
947
|
-
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(svfSuccInst);
|
|
967
|
+
const ICFGNode* icfgNode = llvmModuleSet()->getICFGNode(succInst);
|
|
948
968
|
successors.push_back(std::make_pair(icfgNode, 1-branchID));
|
|
949
969
|
branchID++;
|
|
950
970
|
}
|
|
@@ -1013,8 +1033,7 @@ void SVFIRBuilder::visitSwitchInst(SwitchInst &inst)
|
|
|
1013
1033
|
s64_t val = -1;
|
|
1014
1034
|
if (condVal && condVal->getBitWidth() <= 64)
|
|
1015
1035
|
val = condVal->getSExtValue();
|
|
1016
|
-
const
|
|
1017
|
-
const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(svfSuccInst);
|
|
1036
|
+
const ICFGNode* icfgNode = llvmModuleSet()->getICFGNode(succInst);
|
|
1018
1037
|
successors.push_back(std::make_pair(icfgNode, val));
|
|
1019
1038
|
}
|
|
1020
1039
|
addBranchStmt(brinst, cond, successors);
|
|
@@ -1057,10 +1076,10 @@ void SVFIRBuilder::handleDirectCall(CallBase* cs, const Function *F)
|
|
|
1057
1076
|
{
|
|
1058
1077
|
|
|
1059
1078
|
assert(F);
|
|
1060
|
-
|
|
1061
|
-
const SVFFunction* svffun =
|
|
1079
|
+
CallICFGNode* callICFGNode = llvmModuleSet()->getCallICFGNode(cs);
|
|
1080
|
+
const SVFFunction* svffun = llvmModuleSet()->getSVFFunction(F);
|
|
1062
1081
|
DBOUT(DPAGBuild,
|
|
1063
|
-
outs() << "handle direct call " <<
|
|
1082
|
+
outs() << "handle direct call " << LLVMUtil::dumpValue(cs) << " callee " << F->getName().str() << "\n");
|
|
1064
1083
|
|
|
1065
1084
|
//Only handle the ret.val. if it's used as a ptr.
|
|
1066
1085
|
NodeID dstrec = getValueNode(cs);
|
|
@@ -1068,7 +1087,6 @@ void SVFIRBuilder::handleDirectCall(CallBase* cs, const Function *F)
|
|
|
1068
1087
|
if (!cs->getType()->isVoidTy())
|
|
1069
1088
|
{
|
|
1070
1089
|
NodeID srcret = getReturnNode(svffun);
|
|
1071
|
-
CallICFGNode* callICFGNode = pag->getICFG()->getCallICFGNode(svfcall);
|
|
1072
1090
|
FunExitICFGNode* exitICFGNode = pag->getICFG()->getFunExitICFGNode(svffun);
|
|
1073
1091
|
addRetEdge(srcret, dstrec,callICFGNode, exitICFGNode);
|
|
1074
1092
|
}
|
|
@@ -1087,13 +1105,12 @@ void SVFIRBuilder::handleDirectCall(CallBase* cs, const Function *F)
|
|
|
1087
1105
|
}
|
|
1088
1106
|
const Value* AA = cs->getArgOperand(itA), *FA = &*itF; //current actual/formal arg
|
|
1089
1107
|
|
|
1090
|
-
DBOUT(DPAGBuild, outs() << "process actual parm " <<
|
|
1108
|
+
DBOUT(DPAGBuild, outs() << "process actual parm " << llvmModuleSet()->getSVFValue(AA)->toString() << " \n");
|
|
1091
1109
|
|
|
1092
1110
|
NodeID dstFA = getValueNode(FA);
|
|
1093
1111
|
NodeID srcAA = getValueNode(AA);
|
|
1094
|
-
CallICFGNode* icfgNode = pag->getICFG()->getCallICFGNode(svfcall);
|
|
1095
1112
|
FunEntryICFGNode* entry = pag->getICFG()->getFunEntryICFGNode(svffun);
|
|
1096
|
-
addCallEdge(srcAA, dstFA,
|
|
1113
|
+
addCallEdge(srcAA, dstFA, callICFGNode, entry);
|
|
1097
1114
|
}
|
|
1098
1115
|
//Any remaining actual args must be varargs.
|
|
1099
1116
|
if (F->isVarArg())
|
|
@@ -1104,9 +1121,8 @@ void SVFIRBuilder::handleDirectCall(CallBase* cs, const Function *F)
|
|
|
1104
1121
|
{
|
|
1105
1122
|
const Value* AA = cs->getArgOperand(itA);
|
|
1106
1123
|
NodeID vnAA = getValueNode(AA);
|
|
1107
|
-
CallICFGNode* icfgNode = pag->getICFG()->getCallICFGNode(svfcall);
|
|
1108
1124
|
FunEntryICFGNode* entry = pag->getICFG()->getFunEntryICFGNode(svffun);
|
|
1109
|
-
addCallEdge(vnAA,vaF,
|
|
1125
|
+
addCallEdge(vnAA,vaF, callICFGNode,entry);
|
|
1110
1126
|
}
|
|
1111
1127
|
}
|
|
1112
1128
|
if(itA != ieA)
|
|
@@ -1114,7 +1130,7 @@ void SVFIRBuilder::handleDirectCall(CallBase* cs, const Function *F)
|
|
|
1114
1130
|
/// FIXME: this assertion should be placed for correct checking except
|
|
1115
1131
|
/// bug program like 188.ammp, 300.twolf
|
|
1116
1132
|
writeWrnMsg("too many args to non-vararg func.");
|
|
1117
|
-
writeWrnMsg("(" +
|
|
1133
|
+
writeWrnMsg("(" + callICFGNode->getSourceLoc() + ")");
|
|
1118
1134
|
|
|
1119
1135
|
}
|
|
1120
1136
|
}
|
|
@@ -1142,10 +1158,9 @@ const Value* SVFIRBuilder::getBaseValueForExtArg(const Value* V)
|
|
|
1142
1158
|
*/
|
|
1143
1159
|
void SVFIRBuilder::handleIndCall(CallBase* cs)
|
|
1144
1160
|
{
|
|
1145
|
-
const
|
|
1146
|
-
const SVFValue* svfcalledval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(cs->getCalledOperand());
|
|
1161
|
+
const SVFValue* svfcalledval = llvmModuleSet()->getSVFValue(cs->getCalledOperand());
|
|
1147
1162
|
|
|
1148
|
-
const CallICFGNode* cbn =
|
|
1163
|
+
const CallICFGNode* cbn = llvmModuleSet()->getCallICFGNode(cs);
|
|
1149
1164
|
pag->addIndirectCallsites(cbn,pag->getValueNode(svfcalledval));
|
|
1150
1165
|
}
|
|
1151
1166
|
|
|
@@ -1156,17 +1171,17 @@ void SVFIRBuilder::updateCallGraph(CallGraph* callgraph)
|
|
|
1156
1171
|
for (; iter != eiter; iter++)
|
|
1157
1172
|
{
|
|
1158
1173
|
const CallICFGNode* callBlock = iter->first;
|
|
1159
|
-
const CallBase* callbase = SVFUtil::cast<CallBase>(
|
|
1174
|
+
const CallBase* callbase = SVFUtil::cast<CallBase>(llvmModuleSet()->getLLVMValue(callBlock->getCallSite()));
|
|
1160
1175
|
assert(callBlock->isIndirectCall() && "this is not an indirect call?");
|
|
1161
1176
|
const CallGraph::FunctionSet& functions = iter->second;
|
|
1162
1177
|
for (CallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
|
|
1163
1178
|
{
|
|
1164
|
-
const Function* callee = SVFUtil::cast<Function>(
|
|
1179
|
+
const Function* callee = SVFUtil::cast<Function>(llvmModuleSet()->getLLVMValue(*func_iter));
|
|
1165
1180
|
|
|
1166
1181
|
if (isExtCall(*func_iter))
|
|
1167
1182
|
{
|
|
1168
1183
|
setCurrentLocation(callee, callee->empty() ? nullptr : &callee->getEntryBlock());
|
|
1169
|
-
const SVFFunction* svfcallee =
|
|
1184
|
+
const SVFFunction* svfcallee = llvmModuleSet()->getSVFFunction(callee);
|
|
1170
1185
|
handleExtCall(callbase, svfcallee);
|
|
1171
1186
|
}
|
|
1172
1187
|
else
|
|
@@ -1233,7 +1248,7 @@ NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ap, const
|
|
|
1233
1248
|
const SVFValue* cval = getCurrentValue();
|
|
1234
1249
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
1235
1250
|
setCurrentLocation(curVal, nullptr);
|
|
1236
|
-
LLVMModuleSet* llvmmodule =
|
|
1251
|
+
LLVMModuleSet* llvmmodule = llvmModuleSet();
|
|
1237
1252
|
NodeID gepNode = pag->addGepValNode(curVal, llvmmodule->getSVFValue(val), ap,
|
|
1238
1253
|
NodeIDAllocator::get()->allocateValueId(),
|
|
1239
1254
|
llvmmodule->getSVFType(PointerType::getUnqual(llvmmodule->getContext())));
|
|
@@ -1270,6 +1285,7 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1270
1285
|
// backmap in valuToEdgeMap
|
|
1271
1286
|
pag->mapValueToEdge(curVal, edge);
|
|
1272
1287
|
ICFGNode* icfgNode = pag->getICFG()->getGlobalICFGNode();
|
|
1288
|
+
LLVMModuleSet* llvmMS = llvmModuleSet();
|
|
1273
1289
|
if (const SVFInstruction* curInst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
|
|
1274
1290
|
{
|
|
1275
1291
|
const SVFFunction* srcFun = edge->getSrcNode()->getFunction();
|
|
@@ -1295,9 +1311,9 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1295
1311
|
else
|
|
1296
1312
|
{
|
|
1297
1313
|
if(SVFUtil::isa<RetPE>(edge))
|
|
1298
|
-
icfgNode =
|
|
1314
|
+
icfgNode = llvmMS->getRetICFGNode(SVFUtil::cast<Instruction>(llvmMS->getLLVMValue(curInst)));
|
|
1299
1315
|
else
|
|
1300
|
-
icfgNode =
|
|
1316
|
+
icfgNode = llvmMS->getICFGNode(SVFUtil::cast<Instruction>(llvmMS->getLLVMValue(curInst)));
|
|
1301
1317
|
}
|
|
1302
1318
|
}
|
|
1303
1319
|
else if (const SVFArgument* arg = SVFUtil::dyn_cast<SVFArgument>(curVal))
|
|
@@ -63,7 +63,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
|
|
|
63
63
|
{
|
|
64
64
|
SymbolTableBuilder builder(pag->getSymbolInfo());
|
|
65
65
|
builder.collectSym(offset);
|
|
66
|
-
pag->addValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset));
|
|
66
|
+
pag->addValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset), nullptr);
|
|
67
67
|
}
|
|
68
68
|
ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
|
|
69
69
|
fields.push_back(ls);
|
|
@@ -125,7 +125,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
125
125
|
{
|
|
126
126
|
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
|
|
127
127
|
const SVFCallInst* svfCall = SVFUtil::cast<SVFCallInst>(svfInst);
|
|
128
|
-
const CallICFGNode *callICFGNode =
|
|
128
|
+
const CallICFGNode *callICFGNode = llvmModuleSet()->getCallICFGNode(cs);
|
|
129
129
|
|
|
130
130
|
if (isHeapAllocExtCallViaRet(callICFGNode))
|
|
131
131
|
{
|
|
@@ -259,7 +259,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
259
259
|
if (const SVFFunction* forkedFun = SVFUtil::dyn_cast<SVFFunction>(getForkedFun(callICFGNode)))
|
|
260
260
|
{
|
|
261
261
|
forkedFun = forkedFun->getDefFunForMultipleModule();
|
|
262
|
-
const
|
|
262
|
+
const SVFVar* actualParm = getActualParmAtForkSite(callICFGNode);
|
|
263
263
|
/// pthread_create has 1 arg.
|
|
264
264
|
/// apr_thread_create has 2 arg.
|
|
265
265
|
assert((forkedFun->arg_size() <= 2) && "Size of formal parameter of start routine should be one");
|
|
@@ -267,10 +267,10 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
267
267
|
{
|
|
268
268
|
const SVFArgument* formalParm = forkedFun->getArg(0);
|
|
269
269
|
/// Connect actual parameter to formal parameter of the start routine
|
|
270
|
-
if (actualParm->
|
|
270
|
+
if (actualParm->isPointer() && formalParm->getType()->isPointerTy())
|
|
271
271
|
{
|
|
272
272
|
FunEntryICFGNode *entry = pag->getICFG()->getFunEntryICFGNode(forkedFun);
|
|
273
|
-
addThreadForkEdge(
|
|
273
|
+
addThreadForkEdge(actualParm->getId(), pag->getValueNode(formalParm), callICFGNode, entry);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -318,11 +318,11 @@ void SymbolTableBuilder::collectVal(const Value* val)
|
|
|
318
318
|
void SymbolTableBuilder::collectObj(const Value* val)
|
|
319
319
|
{
|
|
320
320
|
val = LLVMUtil::getGlobalRep(val);
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
LLVMModuleSet* llvmModuleSet = LLVMModuleSet::getLLVMModuleSet();
|
|
322
|
+
SymbolTableInfo::ValueToIDMapTy::iterator iter = symInfo->objSymMap.find(llvmModuleSet->getSVFValue(val));
|
|
323
323
|
if (iter == symInfo->objSymMap.end())
|
|
324
324
|
{
|
|
325
|
-
SVFValue* svfVal =
|
|
325
|
+
SVFValue* svfVal = llvmModuleSet->getSVFValue(val);
|
|
326
326
|
// if the object pointed by the pointer is a constant data (e.g., i32 0) or a global constant object (e.g. string)
|
|
327
327
|
// then we treat them as one ConstantObj
|
|
328
328
|
if (isConstantObjSym(val) && !symInfo->getModelConstants())
|
|
@@ -341,7 +341,7 @@ void SymbolTableBuilder::collectObj(const Value* val)
|
|
|
341
341
|
// create a memory object
|
|
342
342
|
MemObj* mem =
|
|
343
343
|
new MemObj(id, createObjTypeInfo(val),
|
|
344
|
-
|
|
344
|
+
llvmModuleSet->getSVFValue(val));
|
|
345
345
|
assert(symInfo->objMap.find(id) == symInfo->objMap.end());
|
|
346
346
|
symInfo->objMap[id] = mem;
|
|
347
347
|
}
|