svf-tools 1.0.1047 → 1.0.1048
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-llvm/include/SVF-LLVM/LLVMModule.h +14 -15
- package/svf-llvm/include/SVF-LLVM/SVFLLVMValue.h +3 -250
- package/svf-llvm/include/SVF-LLVM/SVFModule.h +8 -10
- package/svf-llvm/lib/DCHG.cpp +1 -1
- package/svf-llvm/lib/LLVMModule.cpp +20 -71
- package/svf-llvm/lib/SVFIRBuilder.cpp +5 -5
- package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -6
- package/svf-llvm/lib/SVFModule.cpp +5 -1
- package/svf-llvm/lib/SymbolTableBuilder.cpp +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1048",
|
|
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": {
|
|
@@ -58,9 +58,9 @@ public:
|
|
|
58
58
|
typedef Map<const Function*, FunObjVar*> LLVMFun2FunObjVarMap;
|
|
59
59
|
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
|
|
60
60
|
typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
|
|
61
|
-
typedef Map<const Argument*,
|
|
62
|
-
typedef Map<const Constant*,
|
|
63
|
-
typedef Map<const Value*,
|
|
61
|
+
typedef Map<const Argument*, SVFLLVMValue*> LLVMArgument2SVFArgumentMap;
|
|
62
|
+
typedef Map<const Constant*, SVFLLVMValue*> LLVMConst2SVFConstMap;
|
|
63
|
+
typedef Map<const Value*, SVFLLVMValue*> LLVMValue2SVFOtherValueMap;
|
|
64
64
|
typedef Map<const SVFLLVMValue*, const Value*> SVFValue2LLVMValueMap;
|
|
65
65
|
typedef Map<const SVFValue*, const Value*> SVFBaseNode2LLVMValueMap;
|
|
66
66
|
typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
|
|
@@ -254,12 +254,12 @@ public:
|
|
|
254
254
|
addToSVFVar2LLVMValueMap(inst, svfInst);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
inline void addArgumentMap(const Argument* arg,
|
|
257
|
+
inline void addArgumentMap(const Argument* arg, SVFLLVMValue* svfArg)
|
|
258
258
|
{
|
|
259
259
|
LLVMArgument2SVFArgument[arg] = svfArg;
|
|
260
260
|
setValueAttr(arg,svfArg);
|
|
261
261
|
}
|
|
262
|
-
inline void addGlobalValueMap(const GlobalValue* glob,
|
|
262
|
+
inline void addGlobalValueMap(const GlobalValue* glob, SVFLLVMValue* svfglob)
|
|
263
263
|
{
|
|
264
264
|
if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(glob);
|
|
265
265
|
hasGlobalRep(glob_var))
|
|
@@ -269,17 +269,17 @@ public:
|
|
|
269
269
|
LLVMConst2SVFConst[glob] = svfglob;
|
|
270
270
|
setValueAttr(glob,svfglob);
|
|
271
271
|
}
|
|
272
|
-
inline void addConstantDataMap(const ConstantData* cd,
|
|
272
|
+
inline void addConstantDataMap(const ConstantData* cd, SVFLLVMValue* svfcd)
|
|
273
273
|
{
|
|
274
274
|
LLVMConst2SVFConst[cd] = svfcd;
|
|
275
275
|
setValueAttr(cd,svfcd);
|
|
276
276
|
}
|
|
277
|
-
inline void addOtherConstantMap(const Constant* cons,
|
|
277
|
+
inline void addOtherConstantMap(const Constant* cons, SVFLLVMValue* svfcons)
|
|
278
278
|
{
|
|
279
279
|
LLVMConst2SVFConst[cons] = svfcons;
|
|
280
280
|
setValueAttr(cons,svfcons);
|
|
281
281
|
}
|
|
282
|
-
inline void addOtherValueMap(const Value* ov,
|
|
282
|
+
inline void addOtherValueMap(const Value* ov, SVFLLVMValue* svfov)
|
|
283
283
|
{
|
|
284
284
|
LLVMValue2SVFOtherValue[ov] = svfov;
|
|
285
285
|
setValueAttr(ov,svfov);
|
|
@@ -353,14 +353,14 @@ public:
|
|
|
353
353
|
return it->second;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
inline
|
|
356
|
+
inline SVFLLVMValue* getSVFArgument(const Argument* arg) const
|
|
357
357
|
{
|
|
358
358
|
LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
|
|
359
359
|
assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
|
|
360
360
|
return it->second;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
inline
|
|
363
|
+
inline SVFLLVMValue* getSVFGlobalValue(const GlobalValue* g) const
|
|
364
364
|
{
|
|
365
365
|
if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(g);
|
|
366
366
|
hasGlobalRep(glob_var))
|
|
@@ -369,14 +369,13 @@ public:
|
|
|
369
369
|
}
|
|
370
370
|
LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(g);
|
|
371
371
|
assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");
|
|
372
|
-
|
|
373
|
-
return SVFUtil::cast<SVFGlobalValue>(it->second);
|
|
372
|
+
return it->second;
|
|
374
373
|
}
|
|
375
374
|
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
SVFLLVMValue* getSVFConstantData(const ConstantData* cd);
|
|
376
|
+
SVFLLVMValue* getOtherSVFConstant(const Constant* oc);
|
|
378
377
|
|
|
379
|
-
|
|
378
|
+
SVFLLVMValue* getSVFOtherValue(const Value* ov);
|
|
380
379
|
|
|
381
380
|
/// Get the corresponding Function based on its name
|
|
382
381
|
inline const SVFFunction* getSVFFunction(const std::string& name)
|
|
@@ -63,16 +63,7 @@ public:
|
|
|
63
63
|
{
|
|
64
64
|
SVFVal,
|
|
65
65
|
SVFFunc,
|
|
66
|
-
SVFBB,
|
|
67
66
|
SVFInst,
|
|
68
|
-
SVFCall,
|
|
69
|
-
SVFVCall,
|
|
70
|
-
SVFGlob,
|
|
71
|
-
SVFArg,
|
|
72
|
-
SVFConst,
|
|
73
|
-
SVFConstData,
|
|
74
|
-
SVFMetaAsValue,
|
|
75
|
-
SVFOther
|
|
76
67
|
};
|
|
77
68
|
|
|
78
69
|
private:
|
|
@@ -85,9 +76,9 @@ protected:
|
|
|
85
76
|
std::string name; ///< Short name of value for printing & debugging
|
|
86
77
|
std::string sourceLoc; ///< Source code information of this value
|
|
87
78
|
/// Constructor without name
|
|
88
|
-
SVFLLVMValue(const SVFType* ty, SVFValKind k)
|
|
79
|
+
SVFLLVMValue(const SVFType* ty, SVFValKind k = SVFVal)
|
|
89
80
|
: kind(k), ptrInUncalledFun(false),
|
|
90
|
-
constDataOrAggData(
|
|
81
|
+
constDataOrAggData(false), type(ty), sourceLoc("NoLoc")
|
|
91
82
|
{
|
|
92
83
|
}
|
|
93
84
|
|
|
@@ -405,9 +396,7 @@ public:
|
|
|
405
396
|
|
|
406
397
|
static inline bool classof(const SVFLLVMValue *node)
|
|
407
398
|
{
|
|
408
|
-
return node->getKind() == SVFInst
|
|
409
|
-
node->getKind() == SVFCall ||
|
|
410
|
-
node->getKind() == SVFVCall;
|
|
399
|
+
return node->getKind() == SVFInst;
|
|
411
400
|
}
|
|
412
401
|
|
|
413
402
|
inline const SVFBasicBlock* getParent() const
|
|
@@ -426,242 +415,6 @@ public:
|
|
|
426
415
|
}
|
|
427
416
|
};
|
|
428
417
|
|
|
429
|
-
class SVFCallInst : public SVFInstruction
|
|
430
|
-
{
|
|
431
|
-
friend class SVFIRWriter;
|
|
432
|
-
friend class SVFIRReader;
|
|
433
|
-
friend class LLVMModuleSet;
|
|
434
|
-
friend class SVFIRBuilder;
|
|
435
|
-
|
|
436
|
-
private:
|
|
437
|
-
std::vector<const SVFLLVMValue*> args;
|
|
438
|
-
bool varArg;
|
|
439
|
-
const SVFLLVMValue* calledVal;
|
|
440
|
-
|
|
441
|
-
protected:
|
|
442
|
-
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
443
|
-
inline void addArgument(const SVFLLVMValue* a)
|
|
444
|
-
{
|
|
445
|
-
args.push_back(a);
|
|
446
|
-
}
|
|
447
|
-
inline void setCalledOperand(const SVFLLVMValue* v)
|
|
448
|
-
{
|
|
449
|
-
calledVal = v;
|
|
450
|
-
}
|
|
451
|
-
/// @}
|
|
452
|
-
|
|
453
|
-
public:
|
|
454
|
-
SVFCallInst(const SVFType* ty, const SVFBasicBlock* b, bool va, bool tm, SVFValKind k = SVFCall) :
|
|
455
|
-
SVFInstruction(ty, b, tm, false, k), varArg(va), calledVal(nullptr)
|
|
456
|
-
{
|
|
457
|
-
}
|
|
458
|
-
SVFCallInst(void) = delete;
|
|
459
|
-
|
|
460
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
461
|
-
{
|
|
462
|
-
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
463
|
-
}
|
|
464
|
-
static inline bool classof(const SVFInstruction *node)
|
|
465
|
-
{
|
|
466
|
-
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
467
|
-
}
|
|
468
|
-
inline u32_t arg_size() const
|
|
469
|
-
{
|
|
470
|
-
return args.size();
|
|
471
|
-
}
|
|
472
|
-
inline bool arg_empty() const
|
|
473
|
-
{
|
|
474
|
-
return args.empty();
|
|
475
|
-
}
|
|
476
|
-
inline const SVFLLVMValue* getArgOperand(u32_t i) const
|
|
477
|
-
{
|
|
478
|
-
assert(i < arg_size() && "out of bound access of the argument");
|
|
479
|
-
return args[i];
|
|
480
|
-
}
|
|
481
|
-
inline u32_t getNumArgOperands() const
|
|
482
|
-
{
|
|
483
|
-
return arg_size();
|
|
484
|
-
}
|
|
485
|
-
inline const SVFLLVMValue* getCalledOperand() const
|
|
486
|
-
{
|
|
487
|
-
return calledVal;
|
|
488
|
-
}
|
|
489
|
-
inline bool isVarArg() const
|
|
490
|
-
{
|
|
491
|
-
return varArg;
|
|
492
|
-
}
|
|
493
|
-
inline const SVFFunction* getCalledFunction() const
|
|
494
|
-
{
|
|
495
|
-
return SVFUtil::dyn_cast<SVFFunction>(calledVal);
|
|
496
|
-
}
|
|
497
|
-
inline const FunObjVar* getCaller() const
|
|
498
|
-
{
|
|
499
|
-
return getFunction();
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
class SVFConstant : public SVFLLVMValue
|
|
504
|
-
{
|
|
505
|
-
friend class SVFIRWriter;
|
|
506
|
-
friend class SVFIRReader;
|
|
507
|
-
public:
|
|
508
|
-
SVFConstant(const SVFType* ty, SVFValKind k = SVFConst): SVFLLVMValue(ty, k)
|
|
509
|
-
{
|
|
510
|
-
}
|
|
511
|
-
SVFConstant() = delete;
|
|
512
|
-
|
|
513
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
514
|
-
{
|
|
515
|
-
return node->getKind() == SVFConst ||
|
|
516
|
-
node->getKind() == SVFGlob ||
|
|
517
|
-
node->getKind() == SVFConstData;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
class SVFGlobalValue : public SVFConstant
|
|
523
|
-
{
|
|
524
|
-
friend class SVFIRWriter;
|
|
525
|
-
friend class SVFIRReader;
|
|
526
|
-
friend class LLVMModuleSet;
|
|
527
|
-
|
|
528
|
-
private:
|
|
529
|
-
const SVFLLVMValue* realDefGlobal; /// the definition of a function across multiple modules
|
|
530
|
-
|
|
531
|
-
protected:
|
|
532
|
-
inline void setDefGlobalForMultipleModule(const SVFLLVMValue* defg)
|
|
533
|
-
{
|
|
534
|
-
realDefGlobal = defg;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
public:
|
|
538
|
-
SVFGlobalValue(const SVFType* ty): SVFConstant(ty, SVFLLVMValue::SVFGlob), realDefGlobal(nullptr)
|
|
539
|
-
{
|
|
540
|
-
}
|
|
541
|
-
SVFGlobalValue(std::string&& name, const SVFType* ty) : SVFGlobalValue(ty)
|
|
542
|
-
{
|
|
543
|
-
setName(std::move(name));
|
|
544
|
-
}
|
|
545
|
-
SVFGlobalValue() = delete;
|
|
546
|
-
|
|
547
|
-
inline const SVFLLVMValue* getDefGlobalForMultipleModule() const
|
|
548
|
-
{
|
|
549
|
-
if(realDefGlobal==nullptr)
|
|
550
|
-
return this;
|
|
551
|
-
return realDefGlobal;
|
|
552
|
-
}
|
|
553
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
554
|
-
{
|
|
555
|
-
return node->getKind() == SVFGlob;
|
|
556
|
-
}
|
|
557
|
-
static inline bool classof(const SVFConstant *node)
|
|
558
|
-
{
|
|
559
|
-
return node->getKind() == SVFGlob;
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
class SVFArgument : public SVFLLVMValue
|
|
564
|
-
{
|
|
565
|
-
friend class SVFIRWriter;
|
|
566
|
-
friend class SVFIRReader;
|
|
567
|
-
private:
|
|
568
|
-
const SVFFunction* fun;
|
|
569
|
-
u32_t argNo;
|
|
570
|
-
bool uncalled;
|
|
571
|
-
public:
|
|
572
|
-
SVFArgument(const SVFType* ty, const SVFFunction* fun, u32_t argNo,
|
|
573
|
-
bool uncalled)
|
|
574
|
-
: SVFLLVMValue(ty, SVFLLVMValue::SVFArg), fun(fun), argNo(argNo),
|
|
575
|
-
uncalled(uncalled)
|
|
576
|
-
{
|
|
577
|
-
}
|
|
578
|
-
SVFArgument() = delete;
|
|
579
|
-
|
|
580
|
-
inline const SVFFunction* getParent() const
|
|
581
|
-
{
|
|
582
|
-
return fun;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/// Return the index of this formal argument in its containing function.
|
|
586
|
-
/// For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
587
|
-
inline u32_t getArgNo() const
|
|
588
|
-
{
|
|
589
|
-
return argNo;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
inline bool isArgOfUncalledFunction() const
|
|
593
|
-
{
|
|
594
|
-
return uncalled;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
598
|
-
{
|
|
599
|
-
return node->getKind() == SVFArg;
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
class SVFConstantData : public SVFConstant
|
|
604
|
-
{
|
|
605
|
-
friend class SVFIRWriter;
|
|
606
|
-
friend class SVFIRReader;
|
|
607
|
-
public:
|
|
608
|
-
SVFConstantData(const SVFType* ty, SVFValKind k = SVFConstData)
|
|
609
|
-
: SVFConstant(ty, k)
|
|
610
|
-
{
|
|
611
|
-
}
|
|
612
|
-
SVFConstantData() = delete;
|
|
613
|
-
|
|
614
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
615
|
-
{
|
|
616
|
-
return node->getKind() == SVFConstData;
|
|
617
|
-
}
|
|
618
|
-
static inline bool classof(const SVFConstantData *node)
|
|
619
|
-
{
|
|
620
|
-
return node->getKind() == SVFConstData;
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
class SVFOtherValue : public SVFLLVMValue
|
|
625
|
-
{
|
|
626
|
-
friend class SVFIRWriter;
|
|
627
|
-
friend class SVFIRReader;
|
|
628
|
-
public:
|
|
629
|
-
SVFOtherValue(const SVFType* ty, SVFValKind k = SVFLLVMValue::SVFOther)
|
|
630
|
-
: SVFLLVMValue(ty, k)
|
|
631
|
-
{
|
|
632
|
-
}
|
|
633
|
-
SVFOtherValue() = delete;
|
|
634
|
-
|
|
635
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
636
|
-
{
|
|
637
|
-
return node->getKind() == SVFOther || node->getKind() == SVFMetaAsValue;
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
/*
|
|
642
|
-
* This class is only for LLVM's MetadataAsValue
|
|
643
|
-
*/
|
|
644
|
-
class SVFMetadataAsValue : public SVFOtherValue
|
|
645
|
-
{
|
|
646
|
-
friend class SVFIRWriter;
|
|
647
|
-
friend class SVFIRReader;
|
|
648
|
-
public:
|
|
649
|
-
SVFMetadataAsValue(const SVFType* ty)
|
|
650
|
-
: SVFOtherValue(ty, SVFLLVMValue::SVFMetaAsValue)
|
|
651
|
-
{
|
|
652
|
-
}
|
|
653
|
-
SVFMetadataAsValue() = delete;
|
|
654
|
-
|
|
655
|
-
static inline bool classof(const SVFLLVMValue *node)
|
|
656
|
-
{
|
|
657
|
-
return node->getKind() == SVFMetaAsValue;
|
|
658
|
-
}
|
|
659
|
-
static inline bool classof(const SVFOtherValue *node)
|
|
660
|
-
{
|
|
661
|
-
return node->getKind() == SVFMetaAsValue;
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
|
|
665
418
|
|
|
666
419
|
/// [FOR DEBUG ONLY, DON'T USE IT UNSIDE `svf`!]
|
|
667
420
|
/// Converts an SVFValue to corresponding LLVM::Value, then get the string
|
|
@@ -44,10 +44,10 @@ class SVFModule
|
|
|
44
44
|
|
|
45
45
|
public:
|
|
46
46
|
typedef std::vector<const SVFFunction*> FunctionSetType;
|
|
47
|
-
typedef std::vector<
|
|
48
|
-
typedef std::vector<
|
|
49
|
-
typedef std::vector<
|
|
50
|
-
typedef std::vector<
|
|
47
|
+
typedef std::vector<SVFLLVMValue*> GlobalSetType;
|
|
48
|
+
typedef std::vector<SVFLLVMValue*> AliasSetType;
|
|
49
|
+
typedef std::vector<SVFLLVMValue*> ConstantType;
|
|
50
|
+
typedef std::vector<SVFLLVMValue*> OtherValueType;
|
|
51
51
|
|
|
52
52
|
/// Iterators type def
|
|
53
53
|
typedef FunctionSetType::iterator iterator;
|
|
@@ -86,21 +86,19 @@ public:
|
|
|
86
86
|
{
|
|
87
87
|
FunctionSet.push_back(svfFunc);
|
|
88
88
|
}
|
|
89
|
-
inline void addGlobalSet(
|
|
89
|
+
inline void addGlobalSet(SVFLLVMValue* glob)
|
|
90
90
|
{
|
|
91
91
|
GlobalSet.push_back(glob);
|
|
92
|
-
addConstant(glob);
|
|
93
92
|
}
|
|
94
|
-
inline void addAliasSet(
|
|
93
|
+
inline void addAliasSet(SVFLLVMValue* alias)
|
|
95
94
|
{
|
|
96
95
|
AliasSet.push_back(alias);
|
|
97
|
-
addConstant(alias);
|
|
98
96
|
}
|
|
99
|
-
inline void addConstant(
|
|
97
|
+
inline void addConstant(SVFLLVMValue* cd)
|
|
100
98
|
{
|
|
101
99
|
ConstantSet.push_back(cd);
|
|
102
100
|
}
|
|
103
|
-
inline void addOtherValue(
|
|
101
|
+
inline void addOtherValue(SVFLLVMValue* ov)
|
|
104
102
|
{
|
|
105
103
|
OtherValueSet.push_back(ov);
|
|
106
104
|
}
|
package/svf-llvm/lib/DCHG.cpp
CHANGED
|
@@ -177,7 +177,7 @@ void DCHGraph::buildVTables(const SVFModule &module)
|
|
|
177
177
|
DIType *type = SVFUtil::dyn_cast<DIType>(gv->getMetadata(cppUtil::ctir::vtMDName));
|
|
178
178
|
assert(type && "DCHG::buildVTables: bad metadata for ctir.vt");
|
|
179
179
|
DCHNode *node = getOrCreateNode(type);
|
|
180
|
-
const
|
|
180
|
+
const SVFLLVMValue* svfgv = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(gv);
|
|
181
181
|
NodeID i = LLVMModuleSet::getLLVMModuleSet()->getObjectNode(svfgv);
|
|
182
182
|
GlobalObjVar* globalObjVar =
|
|
183
183
|
SVFUtil::cast<GlobalObjVar>(PAG::getPAG()->getGNode(i));
|
|
@@ -237,8 +237,7 @@ void LLVMModuleSet::createSVFDataStructure()
|
|
|
237
237
|
/// GlobalVariable
|
|
238
238
|
for (const GlobalVariable& global : mod.globals())
|
|
239
239
|
{
|
|
240
|
-
|
|
241
|
-
global.getName().str(), getSVFType(global.getType()));
|
|
240
|
+
SVFLLVMValue* svfglobal = new SVFLLVMValue(getSVFType(global.getType()));
|
|
242
241
|
svfModule->addGlobalSet(svfglobal);
|
|
243
242
|
addGlobalValueMap(&global, svfglobal);
|
|
244
243
|
}
|
|
@@ -246,8 +245,8 @@ void LLVMModuleSet::createSVFDataStructure()
|
|
|
246
245
|
/// GlobalAlias
|
|
247
246
|
for (const GlobalAlias& alias : mod.aliases())
|
|
248
247
|
{
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
SVFLLVMValue* svfalias = new SVFLLVMValue(
|
|
249
|
+
getSVFType(alias.getType()));
|
|
251
250
|
svfModule->addAliasSet(svfalias);
|
|
252
251
|
addGlobalValueMap(&alias, svfalias);
|
|
253
252
|
}
|
|
@@ -255,8 +254,8 @@ void LLVMModuleSet::createSVFDataStructure()
|
|
|
255
254
|
/// GlobalIFunc
|
|
256
255
|
for (const GlobalIFunc& ifunc : mod.ifuncs())
|
|
257
256
|
{
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
SVFLLVMValue* svfifunc = new SVFLLVMValue(
|
|
258
|
+
getSVFType(ifunc.getType()));
|
|
260
259
|
svfModule->addAliasSet(svfifunc);
|
|
261
260
|
addGlobalValueMap(&ifunc, svfifunc);
|
|
262
261
|
}
|
|
@@ -278,12 +277,8 @@ void LLVMModuleSet::createSVFFunction(const Function* func)
|
|
|
278
277
|
|
|
279
278
|
for (const Argument& arg : func->args())
|
|
280
279
|
{
|
|
281
|
-
|
|
282
|
-
getSVFType(arg.getType())
|
|
283
|
-
LLVMUtil::isArgOfUncalledFunction(&arg));
|
|
284
|
-
// Setting up arg name
|
|
285
|
-
if (!arg.hasName())
|
|
286
|
-
svfarg->setName(std::to_string(arg.getArgNo()));
|
|
280
|
+
SVFLLVMValue* svfarg = new SVFLLVMValue(
|
|
281
|
+
getSVFType(arg.getType()));
|
|
287
282
|
|
|
288
283
|
addArgumentMap(&arg, svfarg);
|
|
289
284
|
}
|
|
@@ -293,21 +288,9 @@ void LLVMModuleSet::createSVFFunction(const Function* func)
|
|
|
293
288
|
addBasicBlock(svfFunc, &bb);
|
|
294
289
|
for (const Instruction& inst : bb)
|
|
295
290
|
{
|
|
296
|
-
SVFInstruction* svfInst =
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
svfInst = new SVFCallInst(
|
|
300
|
-
getSVFType(call->getType()), getSVFBasicBlock(&bb),
|
|
301
|
-
call->getFunctionType()->isVarArg(),
|
|
302
|
-
inst.isTerminator());
|
|
303
|
-
}
|
|
304
|
-
else
|
|
305
|
-
{
|
|
306
|
-
svfInst =
|
|
307
|
-
new SVFInstruction(getSVFType(inst.getType()),
|
|
308
|
-
getSVFBasicBlock(&bb), inst.isTerminator(),
|
|
309
|
-
SVFUtil::isa<ReturnInst>(inst));
|
|
310
|
-
}
|
|
291
|
+
SVFInstruction* svfInst = new SVFInstruction(getSVFType(inst.getType()),
|
|
292
|
+
getSVFBasicBlock(&bb), inst.isTerminator(),
|
|
293
|
+
SVFUtil::isa<ReturnInst>(inst));
|
|
311
294
|
|
|
312
295
|
addInstructionMap(&inst, svfInst);
|
|
313
296
|
}
|
|
@@ -361,31 +344,6 @@ void LLVMModuleSet::initSVFBasicBlock(const Function* func)
|
|
|
361
344
|
svfFun->setExitBlock(svfbb);
|
|
362
345
|
}
|
|
363
346
|
}
|
|
364
|
-
|
|
365
|
-
for (BasicBlock::const_iterator iit = bb->begin(), eiit = bb->end(); iit != eiit; ++iit)
|
|
366
|
-
{
|
|
367
|
-
const Instruction* inst = &*iit;
|
|
368
|
-
if(const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
|
|
369
|
-
{
|
|
370
|
-
SVFInstruction* svfinst = getSVFInstruction(call);
|
|
371
|
-
SVFCallInst* svfcall = SVFUtil::cast<SVFCallInst>(svfinst);
|
|
372
|
-
auto called_llvmval = call->getCalledOperand()->stripPointerCasts();
|
|
373
|
-
if (const Function* called_llvmfunc = SVFUtil::dyn_cast<Function>(called_llvmval))
|
|
374
|
-
{
|
|
375
|
-
SVFFunction* callee = getSVFFunction(called_llvmfunc);
|
|
376
|
-
svfcall->setCalledOperand(callee);
|
|
377
|
-
}
|
|
378
|
-
else
|
|
379
|
-
{
|
|
380
|
-
svfcall->setCalledOperand(getSVFValue(called_llvmval));
|
|
381
|
-
}
|
|
382
|
-
for(u32_t i = 0; i < call->arg_size(); i++)
|
|
383
|
-
{
|
|
384
|
-
SVFLLVMValue* svfval = getSVFValue(call->getArgOperand(i));
|
|
385
|
-
svfcall->addArgument(svfval);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
347
|
}
|
|
390
348
|
// For no return functions, we set the last block as exit BB
|
|
391
349
|
// This ensures that each function that has definition must have an exit BB
|
|
@@ -1234,8 +1192,9 @@ bool LLVMModuleSet::hasValueNode(const SVFLLVMValue *val)
|
|
|
1234
1192
|
NodeID LLVMModuleSet::getObjectNode(const SVFLLVMValue *val)
|
|
1235
1193
|
{
|
|
1236
1194
|
const SVFLLVMValue *svfVal = val;
|
|
1237
|
-
|
|
1238
|
-
|
|
1195
|
+
auto llvm_value = llvmModuleSet->getLLVMValue(svfVal);
|
|
1196
|
+
if (const GlobalVariable* glob = SVFUtil::dyn_cast<GlobalVariable>(llvm_value))
|
|
1197
|
+
svfVal = llvmModuleSet->getSVFValue(LLVMUtil::getGlobalRep(glob));
|
|
1239
1198
|
ValueToIDMapTy::const_iterator iter = objSymMap.find(svfVal);
|
|
1240
1199
|
assert(iter!=objSymMap.end() && "obj sym not found");
|
|
1241
1200
|
return iter->second;
|
|
@@ -1292,12 +1251,6 @@ void LLVMModuleSet::setValueAttr(const Value* val, SVFLLVMValue* svfvalue)
|
|
|
1292
1251
|
if (LLVMUtil::isConstDataOrAggData(val))
|
|
1293
1252
|
svfvalue->setConstDataOrAggData();
|
|
1294
1253
|
|
|
1295
|
-
if (SVFGlobalValue* glob = SVFUtil::dyn_cast<SVFGlobalValue>(svfvalue))
|
|
1296
|
-
{
|
|
1297
|
-
const Value* llvmVal = LLVMUtil::getGlobalRep(val);
|
|
1298
|
-
assert(SVFUtil::isa<GlobalValue>(llvmVal) && "not a GlobalValue?");
|
|
1299
|
-
glob->setDefGlobalForMultipleModule(getSVFGlobalValue(SVFUtil::cast<GlobalValue>(llvmVal)));
|
|
1300
|
-
}
|
|
1301
1254
|
if (SVFFunction* svffun = SVFUtil::dyn_cast<SVFFunction>(svfvalue))
|
|
1302
1255
|
{
|
|
1303
1256
|
const Function* func = SVFUtil::cast<Function>(val);
|
|
@@ -1317,24 +1270,23 @@ void LLVMModuleSet::addToSVFVar2LLVMValueMap(const Value* val,
|
|
|
1317
1270
|
svfBaseNode->setName(val->getName().str());
|
|
1318
1271
|
}
|
|
1319
1272
|
|
|
1320
|
-
|
|
1273
|
+
SVFLLVMValue* LLVMModuleSet::getSVFConstantData(const ConstantData* cd)
|
|
1321
1274
|
{
|
|
1322
1275
|
LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(cd);
|
|
1323
1276
|
if(it!=LLVMConst2SVFConst.end())
|
|
1324
1277
|
{
|
|
1325
|
-
|
|
1326
|
-
return SVFUtil::cast<SVFConstantData>(it->second);
|
|
1278
|
+
return it->second;
|
|
1327
1279
|
}
|
|
1328
1280
|
else
|
|
1329
1281
|
{
|
|
1330
|
-
|
|
1282
|
+
SVFLLVMValue* svfcd = new SVFLLVMValue(getSVFType(cd->getType()));
|
|
1331
1283
|
svfModule->addConstant(svfcd);
|
|
1332
1284
|
addConstantDataMap(cd,svfcd);
|
|
1333
1285
|
return svfcd;
|
|
1334
1286
|
}
|
|
1335
1287
|
}
|
|
1336
1288
|
|
|
1337
|
-
|
|
1289
|
+
SVFLLVMValue* LLVMModuleSet::getOtherSVFConstant(const Constant* oc)
|
|
1338
1290
|
{
|
|
1339
1291
|
LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(oc);
|
|
1340
1292
|
if(it!=LLVMConst2SVFConst.end())
|
|
@@ -1343,14 +1295,14 @@ SVFConstant* LLVMModuleSet::getOtherSVFConstant(const Constant* oc)
|
|
|
1343
1295
|
}
|
|
1344
1296
|
else
|
|
1345
1297
|
{
|
|
1346
|
-
|
|
1298
|
+
SVFLLVMValue* svfoc = new SVFLLVMValue(getSVFType(oc->getType()));
|
|
1347
1299
|
svfModule->addConstant(svfoc);
|
|
1348
1300
|
addOtherConstantMap(oc,svfoc);
|
|
1349
1301
|
return svfoc;
|
|
1350
1302
|
}
|
|
1351
1303
|
}
|
|
1352
1304
|
|
|
1353
|
-
|
|
1305
|
+
SVFLLVMValue* LLVMModuleSet::getSVFOtherValue(const Value* ov)
|
|
1354
1306
|
{
|
|
1355
1307
|
LLVMValue2SVFOtherValueMap::const_iterator it = LLVMValue2SVFOtherValue.find(ov);
|
|
1356
1308
|
if(it!=LLVMValue2SVFOtherValue.end())
|
|
@@ -1359,10 +1311,7 @@ SVFOtherValue* LLVMModuleSet::getSVFOtherValue(const Value* ov)
|
|
|
1359
1311
|
}
|
|
1360
1312
|
else
|
|
1361
1313
|
{
|
|
1362
|
-
|
|
1363
|
-
SVFUtil::isa<MetadataAsValue>(ov)
|
|
1364
|
-
? new SVFMetadataAsValue(getSVFType(ov->getType()))
|
|
1365
|
-
: new SVFOtherValue(getSVFType(ov->getType()));
|
|
1314
|
+
SVFLLVMValue* svfov = new SVFLLVMValue(getSVFType(ov->getType()));
|
|
1366
1315
|
svfModule->addOtherValue(svfov);
|
|
1367
1316
|
addOtherValueMap(ov,svfov);
|
|
1368
1317
|
return svfov;
|
|
@@ -1490,7 +1490,7 @@ NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ap, const
|
|
|
1490
1490
|
* 1. Instruction
|
|
1491
1491
|
* 2. GlobalVariable
|
|
1492
1492
|
*/
|
|
1493
|
-
assert((SVFUtil::isa<SVFInstruction
|
|
1493
|
+
assert((SVFUtil::isa<SVFInstruction>(curVal) || SVFUtil::isa<GlobalVariable>(llvmModuleSet()->getLLVMValue(curVal))) && "curVal not an instruction or a globalvariable?");
|
|
1494
1494
|
|
|
1495
1495
|
// We assume every GepValNode and its GepEdge to the baseNode are unique across the whole program
|
|
1496
1496
|
// We preserve the current BB information to restore it after creating the gepNode
|
|
@@ -1569,15 +1569,15 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1569
1569
|
icfgNode = llvmMS->getICFGNode(SVFUtil::cast<Instruction>(llvmMS->getLLVMValue(curInst)));
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
|
-
else if (const
|
|
1572
|
+
else if (const Argument* arg = SVFUtil::dyn_cast<Argument>(llvmModuleSet()->getLLVMValue(curVal)))
|
|
1573
1573
|
{
|
|
1574
1574
|
assert(curBB && (curBB->getParent()->getEntryBlock() == curBB));
|
|
1575
1575
|
icfgNode = pag->getICFG()->getFunEntryICFGNode(
|
|
1576
|
-
llvmModuleSet()->getFunObjVar(SVFUtil::cast<Function>(
|
|
1576
|
+
llvmModuleSet()->getFunObjVar(SVFUtil::cast<Function>(arg->getParent())));
|
|
1577
1577
|
}
|
|
1578
|
-
else if (SVFUtil::isa<
|
|
1578
|
+
else if (SVFUtil::isa<Constant>(llvmModuleSet()->getLLVMValue(curVal)) ||
|
|
1579
1579
|
SVFUtil::isa<SVFFunction>(curVal) ||
|
|
1580
|
-
SVFUtil::isa<
|
|
1580
|
+
SVFUtil::isa<MetadataAsValue>(llvmModuleSet()->getLLVMValue(curVal)))
|
|
1581
1581
|
{
|
|
1582
1582
|
if (!curBB)
|
|
1583
1583
|
pag->addGlobalPAGEdge(edge);
|
|
@@ -129,7 +129,6 @@ void SVFIRBuilder::addComplexConsForExt(Value *D, Value *S, const Value* szValue
|
|
|
129
129
|
void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCallee)
|
|
130
130
|
{
|
|
131
131
|
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
|
|
132
|
-
const SVFCallInst* svfCall = SVFUtil::cast<SVFCallInst>(svfInst);
|
|
133
132
|
const CallICFGNode *callICFGNode = llvmModuleSet()->getCallICFGNode(cs);
|
|
134
133
|
|
|
135
134
|
if (isHeapAllocExtCallViaRet(callICFGNode))
|
|
@@ -141,7 +140,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
141
140
|
else if (isHeapAllocExtCallViaArg(callICFGNode))
|
|
142
141
|
{
|
|
143
142
|
u32_t arg_pos = LLVMUtil::getHeapAllocHoldingArgPosition(svfCallee);
|
|
144
|
-
const SVFLLVMValue* arg =
|
|
143
|
+
const SVFLLVMValue* arg = llvmModuleSet()->getSVFValue(cs->getArgOperand(arg_pos));
|
|
145
144
|
if (arg->getType()->isPointerTy())
|
|
146
145
|
{
|
|
147
146
|
NodeID vnArg = llvmModuleSet()->getValueNode(arg);
|
|
@@ -166,7 +165,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
166
165
|
addComplexConsForExt(cs->getArgOperand(3), cs->getArgOperand(1), nullptr);
|
|
167
166
|
else if(svfCallee->getName().find("bcopy") != std::string::npos)
|
|
168
167
|
addComplexConsForExt(cs->getArgOperand(1), cs->getArgOperand(0), cs->getArgOperand(2));
|
|
169
|
-
if(
|
|
168
|
+
if(cs->arg_size() == 3)
|
|
170
169
|
addComplexConsForExt(cs->getArgOperand(0), cs->getArgOperand(1), cs->getArgOperand(2));
|
|
171
170
|
else
|
|
172
171
|
addComplexConsForExt(cs->getArgOperand(0), cs->getArgOperand(1), nullptr);
|
|
@@ -233,11 +232,11 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
233
232
|
else if(svfCallee->getName().find("_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_") != std::string::npos)
|
|
234
233
|
{
|
|
235
234
|
// The purpose of this function is to insert a new node into the red-black tree and then rebalance the tree to ensure that the red-black tree properties are maintained.
|
|
236
|
-
assert(
|
|
235
|
+
assert(cs->arg_size() == 4 && "_Rb_tree_insert_and_rebalance should have 4 arguments.\n");
|
|
237
236
|
|
|
238
237
|
// We have vArg3 points to the entry of _Rb_tree_node_base { color; parent; left; right; }.
|
|
239
238
|
// Now we calculate the offset from base to vArg3
|
|
240
|
-
NodeID vnArg3 = llvmModuleSet()->getValueNode(
|
|
239
|
+
NodeID vnArg3 = llvmModuleSet()->getValueNode(llvmModuleSet()->getSVFValue(cs->getArgOperand(3)));
|
|
241
240
|
APOffset offset =
|
|
242
241
|
getAccessPathFromBaseNode(vnArg3).getConstantStructFldIdx();
|
|
243
242
|
|
|
@@ -253,7 +252,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
253
252
|
const SVFType* elementType = pag->getFlatternedElemType(pag->getTypeLocSetsMap(vnArg3).first,
|
|
254
253
|
fields[i].getConstantStructFldIdx());
|
|
255
254
|
NodeID vnD = getGepValVar(cs->getArgOperand(3), fields[i], elementType);
|
|
256
|
-
NodeID vnS = llvmModuleSet()->getValueNode(
|
|
255
|
+
NodeID vnS = llvmModuleSet()->getValueNode(llvmModuleSet()->getSVFValue(cs->getArgOperand(1)));
|
|
257
256
|
if(vnD && vnS)
|
|
258
257
|
addStoreEdge(vnS,vnD);
|
|
259
258
|
}
|
|
@@ -35,7 +35,11 @@ SVFModule::~SVFModule()
|
|
|
35
35
|
{
|
|
36
36
|
for (const SVFFunction* f : FunctionSet)
|
|
37
37
|
delete f;
|
|
38
|
-
for (const
|
|
38
|
+
for (const SVFLLVMValue* v: GlobalSet)
|
|
39
|
+
delete v;
|
|
40
|
+
for (const SVFLLVMValue* v: AliasSet)
|
|
41
|
+
delete v;
|
|
42
|
+
for (const SVFLLVMValue * c : ConstantSet)
|
|
39
43
|
delete c;
|
|
40
44
|
for (const SVFLLVMValue* o : OtherValueSet)
|
|
41
45
|
delete o;
|
|
@@ -592,7 +592,6 @@ const Type* SymbolTableBuilder::inferTypeOfHeapObjOrStaticObj(const Instruction
|
|
|
592
592
|
const PointerType *originalPType = SVFUtil::dyn_cast<PointerType>(inst->getType());
|
|
593
593
|
const Type* inferedType = nullptr;
|
|
594
594
|
assert(originalPType && "empty type?");
|
|
595
|
-
const SVFInstruction* svfinst = llvmModuleSet()->getSVFInstruction(inst);
|
|
596
595
|
if(LLVMUtil::isHeapAllocExtCallViaRet(inst))
|
|
597
596
|
{
|
|
598
597
|
if(const Value* v = getFirstUseViaCastInst(inst))
|
|
@@ -607,7 +606,7 @@ const Type* SymbolTableBuilder::inferTypeOfHeapObjOrStaticObj(const Instruction
|
|
|
607
606
|
else if(LLVMUtil::isHeapAllocExtCallViaArg(inst))
|
|
608
607
|
{
|
|
609
608
|
const CallBase* cs = LLVMUtil::getLLVMCallSite(inst);
|
|
610
|
-
u32_t arg_pos = LLVMUtil::getHeapAllocHoldingArgPosition(
|
|
609
|
+
u32_t arg_pos = LLVMUtil::getHeapAllocHoldingArgPosition(llvmModuleSet()->getSVFFunction(cs->getCalledFunction()));
|
|
611
610
|
const Value* arg = cs->getArgOperand(arg_pos);
|
|
612
611
|
originalPType = SVFUtil::dyn_cast<PointerType>(arg->getType());
|
|
613
612
|
inferedType = inferObjType(startValue = arg);
|