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
8f215683
Commit
8f215683
authored
Nov 16, 2018
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BasicBlockの数を数えるだけのパスを追加
parent
0a126b1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
2 deletions
+92
-2
Makefile
Makefile
+2
-2
CounterPass.cpp
src/nykk/pass/CounterPass.cpp
+87
-0
TestPass.cpp
src/nykk/pass/TestPass.cpp
+3
-0
No files found.
Makefile
View file @
8f215683
...
...
@@ -16,8 +16,8 @@ LDFLAGS := \
all
:
testpass.so
testpass.so
:
src/nykk/pass/TestPass.o
${
CXX
}
${
CXXFLAGS
}
-shared
-o
$@
$
<
${
LDFLAGS
}
testpass.so
:
src/nykk/pass/TestPass.o
src/nykk/pass/CounterPass.o
${
CXX
}
${
CXXFLAGS
}
-shared
-o
$@
$
^
${
LDFLAGS
}
clean
:
${
RM
}
*
.so src/
*
/
*
.o
src/nykk/pass/CounterPass.cpp
0 → 100644
View file @
8f215683
#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
CounterPass
:
public
llvm
::
FunctionPass
{
public
:
static
char
ID
;
// Needed for LLVM.
/**
* @brief Constructor.
*/
explicit
CounterPass
()
:
FunctionPass
(
ID
)
{
}
// Uncopyable, unmovable.
CounterPass
(
const
CounterPass
&
)
=
delete
;
CounterPass
(
CounterPass
&&
)
=
delete
;
CounterPass
&
operator
=
(
const
CounterPass
&
)
=
delete
;
CounterPass
&
operator
=
(
CounterPass
&&
)
=
delete
;
~
CounterPass
()
=
default
;
/**
* @brief Initialization before pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool
doInitialization
(
llvm
::
Module
&
module
)
override
{
llvm
::
errs
()
<<
"[Counter - module ] start: "
<<
module
.
getName
()
<<
"
\n
"
;
return
false
;
}
/**
* @brief Finalization after pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool
doFinalization
(
llvm
::
Module
&
module
)
override
{
llvm
::
errs
()
<<
"[Counter - module ] finish: "
<<
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
()
<<
"[Counter - function ] '"
<<
func
.
getName
()
<<
"' Basic blocks: "
<<
func
.
getBasicBlockList
().
size
()
<<
"
\n
"
;
return
false
;
}
};
char
CounterPass
::
ID
;
// Register pass.
llvm
::
RegisterPass
<
CounterPass
>
counter_pass_registry
{
"counterpass"
,
"IR analyzer"
,
};
}
src/nykk/pass/TestPass.cpp
View file @
8f215683
...
...
@@ -5,6 +5,9 @@
namespace
{
/**
* @brief First watermarker pass.
*/
class
TestPass
:
public
llvm
::
FunctionPass
{
...
...
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