svf-lib 1.0.1647 → 1.0.1648
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.
|
Binary file
|
|
Binary file
|
|
@@ -178,6 +178,10 @@ typedef llvm::BinaryOperator BinaryOperator;
|
|
|
178
178
|
typedef llvm::UnaryOperator UnaryOperator;
|
|
179
179
|
typedef llvm::UndefValue UndefValue;
|
|
180
180
|
|
|
181
|
+
// Related to Switch Case
|
|
182
|
+
typedef std::pair<const BasicBlock*, const ConstantInt*> SuccBBAndCondValPair;
|
|
183
|
+
typedef std::vector<SuccBBAndCondValPair> SuccBBAndCondValPairVec;
|
|
184
|
+
|
|
181
185
|
// LLVM Intrinsic Instructions
|
|
182
186
|
#if LLVM_VERSION_MAJOR >= 13
|
|
183
187
|
typedef llvm::IntrinsicInst IntrinsicInst;
|
|
@@ -519,6 +519,55 @@ std::string llvmToString(const T& val)
|
|
|
519
519
|
llvm::raw_string_ostream(str) << val;
|
|
520
520
|
return str;
|
|
521
521
|
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* See more: https://github.com/SVF-tools/SVF/pull/1191
|
|
525
|
+
*
|
|
526
|
+
* Given the code:
|
|
527
|
+
*
|
|
528
|
+
* switch (a) {
|
|
529
|
+
* case 0: printf("0\n"); break;
|
|
530
|
+
* case 1:
|
|
531
|
+
* case 2:
|
|
532
|
+
* case 3: printf("a >=1 && a <= 3\n"); break;
|
|
533
|
+
* case 4:
|
|
534
|
+
* case 6:
|
|
535
|
+
* case 7: printf("a >= 4 && a <=7\n"); break;
|
|
536
|
+
* default: printf("a < 0 || a > 7"); break;
|
|
537
|
+
* }
|
|
538
|
+
*
|
|
539
|
+
* Generate the IR:
|
|
540
|
+
*
|
|
541
|
+
* switch i32 %0, label %sw.default [
|
|
542
|
+
* i32 0, label %sw.bb
|
|
543
|
+
* i32 1, label %sw.bb1
|
|
544
|
+
* i32 2, label %sw.bb1
|
|
545
|
+
* i32 3, label %sw.bb1
|
|
546
|
+
* i32 4, label %sw.bb3
|
|
547
|
+
* i32 6, label %sw.bb3
|
|
548
|
+
* i32 7, label %sw.bb3
|
|
549
|
+
* ]
|
|
550
|
+
*
|
|
551
|
+
* We can get every case basic block and related case value:
|
|
552
|
+
* [
|
|
553
|
+
* {%sw.default, -1},
|
|
554
|
+
* {%sw.bb, 0},
|
|
555
|
+
* {%sw.bb1, 1},
|
|
556
|
+
* {%sw.bb1, 2},
|
|
557
|
+
* {%sw.bb1, 3},
|
|
558
|
+
* {%sw.bb3, 4},
|
|
559
|
+
* {%sw.bb3, 6},
|
|
560
|
+
* {%sw.bb3, 7},
|
|
561
|
+
* ]
|
|
562
|
+
* Note: default case value is nullptr
|
|
563
|
+
*/
|
|
564
|
+
void getSuccBBandCondValPairVec(const SwitchInst &switchInst, SuccBBAndCondValPairVec &vec);
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Note: default case value is nullptr
|
|
568
|
+
*/
|
|
569
|
+
s64_t getCaseValue(const SwitchInst &switchInst, SuccBBAndCondValPair &succBB2CondVal);
|
|
570
|
+
|
|
522
571
|
} // End namespace LLVMUtil
|
|
523
572
|
|
|
524
573
|
} // End namespace SVF
|