[PATCH] D141579: [PGO] incorrect classof in InstrProfIncrementInst

ZhouKui via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 01:10:31 PST 2023


KuiChou created this revision.
KuiChou added reviewers: phosek, tejohnson, rnk.
KuiChou added a project: LLVM.
Herald added subscribers: ellis, wenlei.
Herald added a project: All.
KuiChou requested review of this revision.
Herald added a subscriber: llvm-commits.

Class InstrProfIncrementInstStep inherits from InstrProfIncrementInst but cannot cast to InstrProfIncrementInst, because InstrProfIncrementInst::classof does not cover such circumstance。

Function InstrProfiling::run traverse all instruction in a module and try to cast them to InstrProfIncrementInst using dyn_cast, but it will return nullptr if the instruction is InstrProfIncrementInstStep(subclass of InstrProfIncrementInst).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141579

Files:
  llvm/include/llvm/IR/IntrinsicInst.h


Index: llvm/include/llvm/IR/IntrinsicInst.h
===================================================================
--- llvm/include/llvm/IR/IntrinsicInst.h
+++ llvm/include/llvm/IR/IntrinsicInst.h
@@ -1350,7 +1350,8 @@
 class InstrProfIncrementInst : public InstrProfInstBase {
 public:
   static bool classof(const IntrinsicInst *I) {
-    return I->getIntrinsicID() == Intrinsic::instrprof_increment;
+    return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
+           I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
   }
   static bool classof(const Value *V) {
     return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141579.488517.patch
Type: text/x-patch
Size: 657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230112/494cd3d7/attachment.bin>


More information about the llvm-commits mailing list