Skip to content

Commit 3b60f89

Browse files
author
Rafael Sá Menezes
committed
added function name option on target pass
1 parent 5387706 commit 3b60f89

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

modules/backend/pass/TargetPass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
#include "TargetPass.hpp"
1212

1313
bool TargetPass::runOnFunction(Function& F) {
14+
llvm::errs() << "Running TargetPass with: " << this->targetFunctionName;
15+
16+
// We need to have the definition of the function
17+
F.getParent()->getOrInsertFunction(
18+
this->targetFunctionName, Type::getVoidTy(F.getContext()));
19+
1420
this->targetFunctionMap2Check = F.getParent()->getOrInsertFunction(
1521
"map2check_target_function", Type::getVoidTy(F.getContext()),
1622
Type::getInt8PtrTy(F.getContext()), Type::getInt32Ty(F.getContext()),

modules/backend/pass/TargetPass.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <llvm/IR/Module.h>
2020
#include <llvm/Pass.h>
2121
#include <llvm/Support/raw_ostream.h>
22+
#include <llvm/Support/CommandLine.h>
2223

2324
#include <iostream>
2425
#include <sstream>
@@ -38,10 +39,15 @@ using llvm::IRBuilder;
3839
using llvm::LLVMContext;
3940
using llvm::RegisterPass;
4041
using llvm::Value;
42+
//using llvm::cl;
4143

44+
// Target option
45+
static llvm::cl::opt<std::string> TargetNameOption("function-name", llvm::cl::desc("Specify the target function"), llvm::cl::init("__VERIFIER_error"));
4246
struct TargetPass : public FunctionPass {
4347
static char ID;
44-
TargetPass() : FunctionPass(ID) {}
48+
TargetPass() : FunctionPass(ID) {
49+
targetFunctionName = TargetNameOption;
50+
}
4551
explicit TargetPass(std::string FunctionName) : FunctionPass(ID) {
4652
targetFunctionName = FunctionName;
4753
}
@@ -56,7 +62,7 @@ struct TargetPass : public FunctionPass {
5662
BasicBlock::iterator currentInstruction;
5763
Constant *targetFunctionMap2Check = NULL;
5864
Value *functionName = NULL;
59-
std::string targetFunctionName = "__VERIFIER_error";
65+
std::string targetFunctionName;
6066
};
6167

6268
#endif // MODULES_BACKEND_PASS_TARGETPASS_HPP_

modules/frontend/caller.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ int Caller::callPass(std::string target_function, bool sv_comp) {
177177
}
178178
case Map2CheckMode::REACHABILITY_MODE: {
179179
Map2Check::Log::Info("Running reachability mode");
180+
Map2Check::Log::Debug("Target function: " + target_function);
180181
std::string targetPass = "${MAP2CHECK_PATH}/lib/libTargetPass";
181182
transformCommand << " -load " << targetPass << getLibSuffix()
182-
<< " -target_function";
183+
<< " -target_function -function-name " << target_function;
183184

184185
break;
185186
}

modules/frontend/map2check.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ int main(int argc, char **argv) {
302302
z3 (Z3 is default), btor (Boolector), and yices2 (Yices))")
303303
("timeout", po::value<unsigned>(),
304304
"\ttimeout for map2check execution")
305-
("target-function", "\tsearches for __VERIFIER_error is reachable")
305+
("target-function", "\tchecks wether <target-functions> is reachable")
306+
("target-function-name", po::value<std::string>()->default_value("__VERIFIER_error"),
307+
R"(define the function name to be searched)")
306308
("generate-testcase", "\tcreates c program with fail testcase (experimental)")
307309
("memtrack", "\tcheck for memory errors")
308310
("print-counter", "\tprint counterexample")
@@ -371,7 +373,7 @@ z3 (Z3 is default), btor (Boolector), and yices2 (Yices))")
371373
args.timeout = timeout;
372374
}
373375
if (vm.count("target-function")) {
374-
string function = "__VERIFIER_error";
376+
string function = vm["target-function-name"].as<string>();
375377
args.function = function;
376378
args.mode = Map2Check::Map2CheckMode::REACHABILITY_MODE;
377379
args.spectTrue = "target-function";

0 commit comments

Comments
 (0)