Commit 2b182eff authored by nagayama15's avatar nagayama15

テスト用のパスを削除

parent 52eaf717
...@@ -18,3 +18,6 @@ benchmark: test ...@@ -18,3 +18,6 @@ benchmark: test
bin/example/zlib/test-inst-wm | tee bin/example/zlib/test-inst-wm.txt bin/example/zlib/test-inst-wm | tee bin/example/zlib/test-inst-wm.txt
bin/example/zlib/test-wm | tee bin/example/zlib/test-wm.txt bin/example/zlib/test-wm | tee bin/example/zlib/test-wm.txt
paste -d"," bin/example/zlib/test.txt bin/example/zlib/test-block-wm.txt bin/example/zlib/test-inst-wm.txt bin/example/zlib/test-wm.txt > bin/example/zlib/test.csv paste -d"," bin/example/zlib/test.txt bin/example/zlib/test-block-wm.txt bin/example/zlib/test-inst-wm.txt bin/example/zlib/test-wm.txt > bin/example/zlib/test.csv
clean::
${MAKE} -C example clean
...@@ -8,5 +8,5 @@ OBJ_DIR := ${ROOT}/obj/${CD:${ROOT}/%=%} ...@@ -8,5 +8,5 @@ OBJ_DIR := ${ROOT}/obj/${CD:${ROOT}/%=%}
.PHONY: all test clean .PHONY: all test clean
clean: clean::
${RM} -r bin obj ${RM} -r bin obj
...@@ -13,3 +13,6 @@ test: ...@@ -13,3 +13,6 @@ test:
${MAKE} -C zlib test ${MAKE} -C zlib test
${MAKE} -C fizzbuzz-rs test ${MAKE} -C fizzbuzz-rs test
${MAKE} -C numguess-rs test ${MAKE} -C numguess-rs test
clean::
${MAKE} -C numguess-rs clean
...@@ -10,7 +10,7 @@ all: ${BIN_DIR}/numguess.out ...@@ -10,7 +10,7 @@ all: ${BIN_DIR}/numguess.out
test: ${BIN_DIR}/numguess.out test: ${BIN_DIR}/numguess.out
clean: clean::
cargo clean cargo clean
${BIN_DIR}/numguess.out: ${BIN_DIR}/numguess.out:
......
TARGET := nykk.so TARGET := nykk.so
SRCS := \ SRCS := \
nykk/pass/BlockCounterPass.cpp \
nykk/pass/BlockWatermarkPass.cpp \ nykk/pass/BlockWatermarkPass.cpp \
nykk/pass/InstructionWatermarkPass.cpp \ nykk/pass/InstructionWatermarkPass.cpp
nykk/pass/TestPass.cpp
include ../cxx.mk include ../cxx.mk
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include <llvm/Pass.h>
#include <llvm/Support/raw_ostream.h>
namespace
{
/**
* @brief Simplest IR analyzer.
*/
class BlockCounterPass
: public llvm::FunctionPass
{
public:
static char ID; // Needed for LLVM.
/**
* @brief Constructor.
*/
explicit BlockCounterPass()
: FunctionPass(ID)
, module_name_()
{
}
// Uncopyable, unmovable.
BlockCounterPass(const BlockCounterPass&) =delete;
BlockCounterPass(BlockCounterPass&&) =delete;
BlockCounterPass& operator=(const BlockCounterPass&) =delete;
BlockCounterPass& operator=(BlockCounterPass&&) =delete;
~BlockCounterPass() =default;
/**
* @brief Initialization before pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool doInitialization(llvm::Module& module) override
{
module_name_ = module.getName();
return false;
}
/**
* @brief Finalization after pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool doFinalization([[maybe_unused]] llvm::Module& module) override
{
module_name_.clear();
return false;
}
/**
* @brief Processes functions.
*
* @param func Reference to the function.
*
* @return `true` if the function was changed.
*/
bool runOnFunction(llvm::Function& func) override
{
llvm::errs()
<< "[BlockCounter - '" << func.getName() << "' in " << module_name_ << "] Basic blocks: " << func.size() << "\n";
return false;
}
private:
std::string module_name_;
};
char BlockCounterPass::ID;
// Registers pass.
const llvm::RegisterPass<BlockCounterPass> pass_registry =
{
"count-block",
"IR analyzer",
};
}
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include <llvm/Pass.h>
#include <llvm/Support/raw_ostream.h>
namespace
{
const llvm::cl::opt<int> test_opt
{
"test_opt",
llvm::cl::desc("Test pass option"),
llvm::cl::value_desc("test"),
llvm::cl::init(10),
};
/**
* @brief First watermarker pass.
*/
class TestPass
: public llvm::FunctionPass
{
public:
static char ID; // Needed for LLVM.
/**
* @brief Constructor.
*/
explicit TestPass()
: FunctionPass(ID)
{
}
// Uncopyable, unmovable.
TestPass(const TestPass&) =delete;
TestPass(TestPass&&) =delete;
TestPass& operator=(const TestPass&) =delete;
TestPass& operator=(TestPass&&) =delete;
~TestPass() =default;
/**
* @brief Initialization before pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool doInitialization(llvm::Module& module) override
{
llvm::errs() << __FUNCTION__ << " : " << module.getName() << "\n";
llvm::errs() << "test_opt: " << test_opt << "\n";
return false;
}
/**
* @brief Finalization after pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool doFinalization(llvm::Module& module) override
{
llvm::errs() << __FUNCTION__ << " : " << module.getName() << "\n";
return false;
}
/**
* @brief Processes functions.
*
* @param func Reference to the function.
*
* @return `true` if the function was changed.
*/
bool runOnFunction(llvm::Function& func) override
{
llvm::errs() << __FUNCTION__ << " : " << func.getName() << "\n";
llvm::errs() << " " << "bbs : " << func.getBasicBlockList().size() << "\n";
if (func.getBasicBlockList().size() < 3)
{
return false;
}
// Swaps 2nd and 3rd basic blocks.
llvm::BasicBlock& entry_bb = func.getEntryBlock();
llvm::BasicBlock* bb1 = entry_bb.getNextNode();
llvm::BasicBlock* bb2 = bb1->getNextNode();
bb1->moveAfter(bb2);
return true;
}
};
char TestPass::ID;
// Registers pass.
const llvm::RegisterPass<TestPass> pass_registry =
{
"testpass",
"Test pass",
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment