Skip to content

Commit 3f7aa04

Browse files
authored
[nfc] Fix RTTI for InstrProf intrinsics (#83511)
1 parent 2a13422 commit 3f7aa04

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,35 @@ class VACopyInst : public IntrinsicInst {
14291429

14301430
/// A base class for all instrprof intrinsics.
14311431
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+
14321453
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+
}
14331461
// The name of the instrumented function.
14341462
GlobalVariable *getName() const {
14351463
return cast<GlobalVariable>(
@@ -1444,6 +1472,12 @@ class InstrProfInstBase : public IntrinsicInst {
14441472
/// A base class for all instrprof counter intrinsics.
14451473
class InstrProfCntrInstBase : public InstrProfInstBase {
14461474
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+
14471481
// The number of counters for the instrumented function.
14481482
ConstantInt *getNumCounters() const;
14491483
// The index of the counter that this instruction acts on.
@@ -1524,8 +1558,7 @@ class InstrProfValueProfileInst : public InstrProfCntrInstBase {
15241558
class InstrProfMCDCBitmapInstBase : public InstrProfInstBase {
15251559
public:
15261560
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);
15291562
}
15301563
static bool classof(const Value *V) {
15311564
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));

0 commit comments

Comments
 (0)