Skip to content

[nfc] Fix RTTI for InstrProf intrinsics #83511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions llvm/include/llvm/IR/IntrinsicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,35 @@ class VACopyInst : public IntrinsicInst {

/// A base class for all instrprof intrinsics.
class InstrProfInstBase : public IntrinsicInst {
protected:
static bool isCounterBase(const IntrinsicInst &I) {
switch (I.getIntrinsicID()) {
case Intrinsic::instrprof_cover:
case Intrinsic::instrprof_increment:
case Intrinsic::instrprof_increment_step:
case Intrinsic::instrprof_timestamp:
case Intrinsic::instrprof_value_profile:
return true;
}
return false;
}
static bool isMCDCBitmapBase(const IntrinsicInst &I) {
switch (I.getIntrinsicID()) {
case Intrinsic::instrprof_mcdc_parameters:
case Intrinsic::instrprof_mcdc_tvbitmap_update:
return true;
}
return false;
}

public:
static bool classof(const Value *V) {
if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr) ||
Instr->getIntrinsicID() ==
Intrinsic::instrprof_mcdc_condbitmap_update;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be in isMCDCBitmapBase() CC @evodius96

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I found the comment for InstrProfMCDCCondBitmapUpdate

return false;
}
// The name of the instrumented function.
GlobalVariable *getName() const {
return cast<GlobalVariable>(
Expand All @@ -1444,6 +1472,12 @@ class InstrProfInstBase : public IntrinsicInst {
/// A base class for all instrprof counter intrinsics.
class InstrProfCntrInstBase : public InstrProfInstBase {
public:
static bool classof(const Value *V) {
if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
return InstrProfInstBase::isCounterBase(*Instr);
return false;
}

// The number of counters for the instrumented function.
ConstantInt *getNumCounters() const;
// The index of the counter that this instruction acts on.
Expand Down Expand Up @@ -1524,8 +1558,7 @@ class InstrProfValueProfileInst : public InstrProfCntrInstBase {
class InstrProfMCDCBitmapInstBase : public InstrProfInstBase {
public:
static bool classof(const IntrinsicInst *I) {
return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters ||
I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
return InstrProfInstBase::isMCDCBitmapBase(*I);
}
static bool classof(const Value *V) {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
Expand Down