Skip to content

Commit

Permalink
Verify valid users of Function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
avp authored and facebook-github-bot committed Feb 6, 2025
1 parent 81e6b58 commit caa0b13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/IR/IRVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseCallInst>(user) ||
llvh::isa<BaseCreateLexicalChildInst>(user) ||
llvh::isa<GetClosureScopeInst>(user),
"Function can only be an operand to certain instructions");
}

FunctionState newFunctionState(this, F);

// Verify all basic blocks are valid
Expand Down

0 comments on commit caa0b13

Please sign in to comment.