From 9005cb0fc8aa04a2aeaef129206eee9676210d65 Mon Sep 17 00:00:00 2001 From: 2over12 Date: Mon, 30 Jan 2023 13:38:38 -0500 Subject: [PATCH] Weaken remill check in utils to allow additional parameters (#650) * weaken remill check in utils to allow additional parameters * more unambiguous name --- lib/BC/Util.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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();