From aabb3852293957b2df093b83a640da1e6a1a8e4a Mon Sep 17 00:00:00 2001 From: Aakash Patel Date: Thu, 14 Nov 2024 13:17:40 -0800 Subject: [PATCH] Use TypeOfIs in inlining Summary: This can be simplified. Reviewed By: neildhar Differential Revision: D65439606 fbshipit-source-id: be15d054c1fd5fe4d1c4da732f2df9cdadf8e18d --- lib/Optimizer/Scalar/Inlining.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Optimizer/Scalar/Inlining.cpp b/lib/Optimizer/Scalar/Inlining.cpp index 4e7d3457967..470607a0ccf 100644 --- a/lib/Optimizer/Scalar/Inlining.cpp +++ b/lib/Optimizer/Scalar/Inlining.cpp @@ -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"); @@ -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);