@@ -530,6 +530,7 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
530530 void visitCallStackMetadata (MDNode *MD);
531531 void visitMemProfMetadata (Instruction &I, MDNode *MD);
532532 void visitCallsiteMetadata (Instruction &I, MDNode *MD);
533+ void visitCalleeTypeMetadata (Instruction &I, MDNode *MD);
533534 void visitDIAssignIDMetadata (Instruction &I, MDNode *MD);
534535 void visitMMRAMetadata (Instruction &I, MDNode *MD);
535536 void visitAnnotationMetadata (MDNode *Annotation);
@@ -5050,6 +5051,20 @@ void Verifier::visitCallsiteMetadata(Instruction &I, MDNode *MD) {
50505051 visitCallStackMetadata (MD);
50515052}
50525053
5054+ void Verifier::visitCalleeTypeMetadata (Instruction &I, MDNode *MD) {
5055+ Check (isa<CallBase>(I), " !callee_type metadata should only exist on calls" ,
5056+ &I);
5057+ CallBase *CB = cast<CallBase>(&I);
5058+ Check (CB->isIndirectCall (),
5059+ " !callee_type metadata should only exist on indirect function calls" ,
5060+ &I);
5061+ for (const auto &Op : MD->operands ()) {
5062+ auto *TypeMD = cast<MDNode>(Op.get ());
5063+ Check (TypeMD->hasGeneralizedMDString (),
5064+ " Invalid \" callee_type\" type identifier" , &I);
5065+ }
5066+ }
5067+
50535068void Verifier::visitAnnotationMetadata (MDNode *Annotation) {
50545069 Check (isa<MDTuple>(Annotation), " annotation must be a tuple" );
50555070 Check (Annotation->getNumOperands () >= 1 ,
@@ -5325,6 +5340,9 @@ void Verifier::visitInstruction(Instruction &I) {
53255340 if (MDNode *MD = I.getMetadata (LLVMContext::MD_callsite))
53265341 visitCallsiteMetadata (I, MD);
53275342
5343+ if (MDNode *MD = I.getMetadata (LLVMContext::MD_callee_type))
5344+ visitCalleeTypeMetadata (I, MD);
5345+
53285346 if (MDNode *MD = I.getMetadata (LLVMContext::MD_DIAssignID))
53295347 visitDIAssignIDMetadata (I, MD);
53305348
0 commit comments