From caa0b13ec4f8df7cb16b51609290bb15737ad3ab Mon Sep 17 00:00:00 2001 From: Aakash Patel Date: Wed, 5 Feb 2025 16:32:58 -0800 Subject: [PATCH] Verify valid users of Function Summary: `Function` only has a few instructions which are allowed to use it directly, so put that in the IRVerifier. Reviewed By: neildhar Differential Revision: D69187679 fbshipit-source-id: a2b407fb94cd8f1da913a0544c3dfec788065064 --- lib/IR/IRVerifier.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/IR/IRVerifier.cpp b/lib/IR/IRVerifier.cpp index 5c87985abd4..ecb877086cb 100644 --- a/lib/IR/IRVerifier.cpp +++ b/lib/IR/IRVerifier.cpp @@ -248,6 +248,15 @@ bool Verifier::visitFunction(const Function &F) { "Only GetNewTargetInst may use the newTargetParam"); } + for (Instruction *user : F.getUsers()) { + AssertIWithMsg( + (*user), + llvh::isa(user) || + llvh::isa(user) || + llvh::isa(user), + "Function can only be an operand to certain instructions"); + } + FunctionState newFunctionState(this, F); // Verify all basic blocks are valid