Skip to content

Commit 175b5f1

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 9ceb54c commit 175b5f1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

llvm/include/llvm/IR/Metadata.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,12 @@ class MDNode : public Metadata {
12591259
bool isReplaceable() const { return isTemporary() || isAlwaysReplaceable(); }
12601260
bool isAlwaysReplaceable() const { return getMetadataID() == DIAssignIDKind; }
12611261

1262+
bool hasGeneralizedMDString() const {
1263+
if (getNumOperands() < 2 || !isa<MDString>(getOperand(1)))
1264+
return false;
1265+
return cast<MDString>(getOperand(1))->getString().ends_with(".generalized");
1266+
}
1267+
12621268
unsigned getNumTemporaryUses() const {
12631269
assert(isTemporary() && "Only for temporaries");
12641270
return Context.getReplaceableUses()->getNumUses();

llvm/lib/IR/Verifier.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
50535068
void 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

Comments
 (0)