Skip to content

Commit

Permalink
Use TypeOfIs in inlining
Browse files Browse the repository at this point in the history
Summary: This can be simplified.

Reviewed By: neildhar

Differential Revision: D65439606

fbshipit-source-id: be15d054c1fd5fe4d1c4da732f2df9cdadf8e18d
  • Loading branch information
avp authored and facebook-github-bot committed Nov 14, 2024
1 parent 0dcfdfa commit aabb385
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Optimizer/Scalar/Inlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ bool Inlining::runOnModule(Module *M) {
IRBuilder builder(M);

// Literal strings for speculative inlining.
auto *functionLS = builder.getLiteralString("function");
auto *nonFunctionErrorLS =
builder.getLiteralString("Trying to call a non-function");

Expand Down Expand Up @@ -626,9 +625,10 @@ bool Inlining::runOnModule(Module *M) {
auto *inlineBB = builder.createBasicBlock(intoFunction);

// Check if typeof callee === 'function', and throw a type error if not.
auto *typeCheck = builder.createTypeOfInst(CI->getCallee());
auto *typeCheckResult = builder.createBinaryOperatorInst(
typeCheck, functionLS, ValueKind::BinaryStrictlyEqualInstKind);
auto *typeCheckResult = builder.createTypeOfIsInst(
CI->getCallee(),
builder.getLiteralTypeOfIsTypes(
TypeOfIsTypes{}.withFunction(true)));
builder.createCondBranchInst(typeCheckResult, inlineBB, throwBB);
builder.setInsertionBlock(throwBB);
builder.createThrowTypeErrorInst(nonFunctionErrorLS);
Expand Down

0 comments on commit aabb385

Please sign in to comment.