aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
diff options
context:
space:
mode:
authorEllis Hoag <ellis.sparky.hoag@gmail.com>2022-01-18 10:38:58 -0800
committerEllis Hoag <ellis.sparky.hoag@gmail.com>2022-01-18 11:12:00 -0800
commit5b9358d774012ea02ca702e28a909c5dd4464a03 (patch)
tree60a64a07c9830abc72f167356acf557ae64cfaeb /llvm/lib/IR/IntrinsicInst.cpp
parent82de129ab8f723ba94d0026b54d76b11b2a9e4f9 (diff)
downloadllvm-5b9358d774012ea02ca702e28a909c5dd4464a03.zip
llvm-5b9358d774012ea02ca702e28a909c5dd4464a03.tar.gz
llvm-5b9358d774012ea02ca702e28a909c5dd4464a03.tar.bz2
[InstrProf][NFC] Add InstrProfInstBase base
The `InstrProfInstBase` class is for all `llvm.instrprof.*` intrinsics. In a later diff we will add new instrinsic of this type. Also refactor some logic in `InstrProfiling.cpp`. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D117261
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r--llvm/lib/IR/IntrinsicInst.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index e7555bf..adea7ab 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -178,6 +178,18 @@ int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
return -1;
}
+ConstantInt *InstrProfInstBase::getNumCounters() const {
+ if (InstrProfValueProfileInst::classof(this))
+ llvm_unreachable("InstrProfValueProfileInst does not have counters!");
+ return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
+}
+
+ConstantInt *InstrProfInstBase::getIndex() const {
+ if (InstrProfValueProfileInst::classof(this))
+ llvm_unreachable("Please use InstrProfValueProfileInst::getIndex()");
+ return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
+}
+
Value *InstrProfIncrementInst::getStep() const {
if (InstrProfIncrementInstStep::classof(this)) {
return const_cast<Value *>(getArgOperand(4));