diff options
author | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2022-01-18 10:38:58 -0800 |
---|---|---|
committer | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2022-01-18 11:12:00 -0800 |
commit | 5b9358d774012ea02ca702e28a909c5dd4464a03 (patch) | |
tree | 60a64a07c9830abc72f167356acf557ae64cfaeb /llvm/lib/IR/IntrinsicInst.cpp | |
parent | 82de129ab8f723ba94d0026b54d76b11b2a9e4f9 (diff) | |
download | llvm-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.cpp | 12 |
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)); |