diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h index 9818a8bcbc2cb..14210ae35c008 100644 --- a/llvm/include/llvm/SandboxIR/SandboxIR.h +++ b/llvm/include/llvm/SandboxIR/SandboxIR.h @@ -2744,6 +2744,10 @@ class AtomicCmpXchgInst AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, BasicBlock *InsertAtEnd, Context &Ctx, SyncScope::ID SSID = SyncScope::System, const Twine &Name = ""); + + static bool classof(const Value *From) { + return From->getSubclassID() == ClassID::AtomicCmpXchg; + } }; class AllocaInst final : public UnaryInstruction { diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp index 016024750baf2..31519074e1b90 100644 --- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp +++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp @@ -4317,3 +4317,10 @@ define void @foo() { EXPECT_EQ(NewUIEnd->getParent(), BB); EXPECT_EQ(NewUIEnd->getNextNode(), nullptr); } + +/// Makes sure that all Instruction sub-classes have a classof(). +TEST_F(SandboxIRTest, CheckClassof) { +#define DEF_INSTR(ID, OPC, CLASS) \ + EXPECT_NE(&sandboxir::CLASS::classof, &sandboxir::Instruction::classof); +#include "llvm/SandboxIR/SandboxIRValues.def" +}