@@ -1429,7 +1429,35 @@ class VACopyInst : public IntrinsicInst {
1429
1429
1430
1430
// / A base class for all instrprof intrinsics.
1431
1431
class InstrProfInstBase : public IntrinsicInst {
1432
+ protected:
1433
+ static bool isCounterBase (const IntrinsicInst &I) {
1434
+ switch (I.getIntrinsicID ()) {
1435
+ case Intrinsic::instrprof_cover:
1436
+ case Intrinsic::instrprof_increment:
1437
+ case Intrinsic::instrprof_increment_step:
1438
+ case Intrinsic::instrprof_timestamp:
1439
+ case Intrinsic::instrprof_value_profile:
1440
+ return true ;
1441
+ }
1442
+ return false ;
1443
+ }
1444
+ static bool isMCDCBitmapBase (const IntrinsicInst &I) {
1445
+ switch (I.getIntrinsicID ()) {
1446
+ case Intrinsic::instrprof_mcdc_parameters:
1447
+ case Intrinsic::instrprof_mcdc_tvbitmap_update:
1448
+ return true ;
1449
+ }
1450
+ return false ;
1451
+ }
1452
+
1432
1453
public:
1454
+ static bool classof (const Value *V) {
1455
+ if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1456
+ return isCounterBase (*Instr) || isMCDCBitmapBase (*Instr) ||
1457
+ Instr->getIntrinsicID () ==
1458
+ Intrinsic::instrprof_mcdc_condbitmap_update;
1459
+ return false ;
1460
+ }
1433
1461
// The name of the instrumented function.
1434
1462
GlobalVariable *getName () const {
1435
1463
return cast<GlobalVariable>(
@@ -1444,6 +1472,12 @@ class InstrProfInstBase : public IntrinsicInst {
1444
1472
// / A base class for all instrprof counter intrinsics.
1445
1473
class InstrProfCntrInstBase : public InstrProfInstBase {
1446
1474
public:
1475
+ static bool classof (const Value *V) {
1476
+ if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1477
+ return InstrProfInstBase::isCounterBase (*Instr);
1478
+ return false ;
1479
+ }
1480
+
1447
1481
// The number of counters for the instrumented function.
1448
1482
ConstantInt *getNumCounters () const ;
1449
1483
// The index of the counter that this instruction acts on.
@@ -1524,8 +1558,7 @@ class InstrProfValueProfileInst : public InstrProfCntrInstBase {
1524
1558
class InstrProfMCDCBitmapInstBase : public InstrProfInstBase {
1525
1559
public:
1526
1560
static bool classof (const IntrinsicInst *I) {
1527
- return I->getIntrinsicID () == Intrinsic::instrprof_mcdc_parameters ||
1528
- I->getIntrinsicID () == Intrinsic::instrprof_mcdc_tvbitmap_update;
1561
+ return InstrProfInstBase::isMCDCBitmapBase (*I);
1529
1562
}
1530
1563
static bool classof (const Value *V) {
1531
1564
return isa<IntrinsicInst>(V) && classof (cast<IntrinsicInst>(V));
0 commit comments