Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
llvm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
llvm-watermarker
Commits
2b182eff
Commit
2b182eff
authored
Dec 28, 2018
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
テスト用のパスを削除
parent
52eaf717
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
9 additions
and
202 deletions
+9
-202
Makefile
Makefile
+3
-0
common.mk
common.mk
+1
-1
Makefile
example/Makefile
+3
-0
Makefile
example/numguess-rs/Makefile
+1
-1
Makefile
src/Makefile
+1
-3
BlockCounterPass.cpp
src/nykk/pass/BlockCounterPass.cpp
+0
-90
TestPass.cpp
src/nykk/pass/TestPass.cpp
+0
-107
No files found.
Makefile
View file @
2b182eff
...
...
@@ -18,3 +18,6 @@ benchmark: test
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
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
common.mk
View file @
2b182eff
...
...
@@ -8,5 +8,5 @@ OBJ_DIR := ${ROOT}/obj/${CD:${ROOT}/%=%}
.PHONY: all test clean
clean:
clean:
:
${RM} -r bin obj
example/Makefile
View file @
2b182eff
...
...
@@ -13,3 +13,6 @@ test:
${
MAKE
}
-C
zlib
test
${
MAKE
}
-C
fizzbuzz-rs
test
${
MAKE
}
-C
numguess-rs
test
clean
::
${
MAKE
}
-C
numguess-rs clean
example/numguess-rs/Makefile
View file @
2b182eff
...
...
@@ -10,7 +10,7 @@ all: ${BIN_DIR}/numguess.out
test
:
${BIN_DIR}/numguess.out
clean
:
clean
:
:
cargo clean
${BIN_DIR}/numguess.out
:
...
...
src/Makefile
View file @
2b182eff
TARGET
:=
nykk.so
SRCS
:=
\
nykk/pass/BlockCounterPass.cpp
\
nykk/pass/BlockWatermarkPass.cpp
\
nykk/pass/InstructionWatermarkPass.cpp
\
nykk/pass/TestPass.cpp
nykk/pass/InstructionWatermarkPass.cpp
include
../cxx.mk
src/nykk/pass/BlockCounterPass.cpp
deleted
100644 → 0
View file @
52eaf717
#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"
,
};
}
src/nykk/pass/TestPass.cpp
deleted
100644 → 0
View file @
52eaf717
#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"
,
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment