|
112 | 112 | #include "llvm/IR/Value.h" |
113 | 113 | #include "llvm/InitializePasses.h" |
114 | 114 | #include "llvm/Pass.h" |
| 115 | +#include "llvm/ProfileData/InstrProf.h" |
115 | 116 | #include "llvm/Support/AMDGPUAddrSpace.h" |
116 | 117 | #include "llvm/Support/AtomicOrdering.h" |
117 | 118 | #include "llvm/Support/Casting.h" |
@@ -5026,9 +5027,23 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) { |
5026 | 5027 | Check(mdconst::dyn_extract<ConstantInt>(MDO), |
5027 | 5028 | "!prof brunch_weights operand is not a const int"); |
5028 | 5029 | } |
| 5030 | + } else if (ProfName == MDProfLabels::ValueProfile) { |
| 5031 | + Check(isValueProfileMD(MD),"invalid value profiling metadata",MD); |
| 5032 | + ConstantInt *KindInt = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1)); |
| 5033 | + Check(KindInt, "VP !prof missing kind argument", MD); |
| 5034 | + |
| 5035 | + auto Kind = KindInt->getZExtValue(); |
| 5036 | + Check(Kind >= InstrProfValueKind::IPVK_First && |
| 5037 | + Kind <= InstrProfValueKind::IPVK_Last, |
| 5038 | + "Invalid VP !prof kind", MD); |
| 5039 | + if (Kind == InstrProfValueKind::IPVK_IndirectCallTarget || |
| 5040 | + Kind == InstrProfValueKind::IPVK_MemOPSize) |
| 5041 | + Check(isa<CallBase>(I), |
| 5042 | + "VP !prof indirect call or memop size expected to be applied to " |
| 5043 | + "CallBase instructions only", |
| 5044 | + MD); |
5029 | 5045 | } else { |
5030 | | - Check(ProfName == MDProfLabels::ValueProfile, |
5031 | | - "expected either branch_weights or VP profile name", MD); |
| 5046 | + CheckFailed("expected either branch_weights or VP profile name", MD); |
5032 | 5047 | } |
5033 | 5048 | } |
5034 | 5049 |
|
|
0 commit comments