diff --git a/lib/BC/Util.cpp b/lib/BC/Util.cpp index cf21555d..63415465 100644 --- a/lib/BC/Util.cpp +++ b/lib/BC/Util.cpp @@ -239,9 +239,14 @@ FindVarInFunction(llvm::Function *function, std::string_view name_, return {nullptr, nullptr}; } +bool HasRemillLiftedFunctionParams(llvm::Function *function) { + return function->arg_size() >= kNumBlockArgs; +} + + // Find the machine state pointer. llvm::Value *LoadStatePointer(llvm::Function *function) { - CHECK(kNumBlockArgs == function->arg_size()) + CHECK(HasRemillLiftedFunctionParams(function)) << "Invalid block-like function. Expected three arguments: state " << "pointer, program counter, and memory pointer in function " << function->getName().str(); @@ -254,7 +259,7 @@ llvm::Value *LoadStatePointer(llvm::Function *function) { // Return the memory pointer argument. llvm::Value *LoadMemoryPointerArg(llvm::Function *function) { - CHECK(kNumBlockArgs == function->arg_size()) + CHECK(HasRemillLiftedFunctionParams(function)) << "Invalid block-like function. Expected three arguments: state " << "pointer, program counter, and memory pointer in function " << function->getName().str(); @@ -267,7 +272,7 @@ llvm::Value *LoadMemoryPointerArg(llvm::Function *function) { // Return the program counter argument. llvm::Value *LoadProgramCounterArg(llvm::Function *function) { - CHECK(kNumBlockArgs == function->arg_size()) + CHECK(HasRemillLiftedFunctionParams(function)) << "Invalid block-like function. Expected three arguments: state " << "pointer, program counter, and memory pointer in function " << function->getName().str();