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
d55e4b4d
Commit
d55e4b4d
authored
Nov 17, 2018
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
コメントを改善
parent
00bb7e5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
BlockCounterPass.cpp
src/nykk/pass/BlockCounterPass.cpp
+1
-1
BlockWatermarkPass.cpp
src/nykk/pass/BlockWatermarkPass.cpp
+13
-6
TestPass.cpp
src/nykk/pass/TestPass.cpp
+2
-2
No files found.
src/nykk/pass/BlockCounterPass.cpp
View file @
d55e4b4d
...
@@ -81,7 +81,7 @@ namespace
...
@@ -81,7 +81,7 @@ namespace
char
BlockCounterPass
::
ID
;
char
BlockCounterPass
::
ID
;
// Register pass.
// Register
s
pass.
const
llvm
::
RegisterPass
<
BlockCounterPass
>
pass_registry
=
const
llvm
::
RegisterPass
<
BlockCounterPass
>
pass_registry
=
{
{
"count-block"
,
"count-block"
,
...
...
src/nykk/pass/BlockWatermarkPass.cpp
View file @
d55e4b4d
...
@@ -7,6 +7,13 @@
...
@@ -7,6 +7,13 @@
namespace
namespace
{
{
/**
* @brief Command line option analyzer.
*
* @tparam Integer Integer type.
* @tparam Min Minimum value to accept.
* @tparam Max Maximum value to accept.
*/
template
<
typename
Integer
,
Integer
Min
,
Integer
Max
>
template
<
typename
Integer
,
Integer
Min
,
Integer
Max
>
class
RangeOptParser
class
RangeOptParser
:
public
llvm
::
cl
::
parser
<
Integer
>
:
public
llvm
::
cl
::
parser
<
Integer
>
...
@@ -16,7 +23,7 @@ namespace
...
@@ -16,7 +23,7 @@ namespace
public
:
public
:
using
llvm
::
cl
::
parser
<
Integer
>::
parser
;
using
llvm
::
cl
::
parser
<
Integer
>::
parser
;
// Return `true` on error.
// Return
s
`true` on error.
bool
parse
(
llvm
::
cl
::
Option
&
o
,
[[
maybe_unused
]]
llvm
::
StringRef
arg_name
,
llvm
::
StringRef
arg
,
Integer
&
val
)
bool
parse
(
llvm
::
cl
::
Option
&
o
,
[[
maybe_unused
]]
llvm
::
StringRef
arg_name
,
llvm
::
StringRef
arg
,
Integer
&
val
)
{
{
try
try
...
@@ -153,7 +160,7 @@ namespace
...
@@ -153,7 +160,7 @@ namespace
const
auto
blocks
=
std
::
vector
<
std
::
reference_wrapper
<
llvm
::
BasicBlock
>>
(
std
::
begin
(
func
),
std
::
end
(
func
));
const
auto
blocks
=
std
::
vector
<
std
::
reference_wrapper
<
llvm
::
BasicBlock
>>
(
std
::
begin
(
func
),
std
::
end
(
func
));
auto
last_block
=
&
func
.
getEntryBlock
();
auto
last_block
=
&
func
.
getEntryBlock
();
// Embed
ding
.
// Embed
s watermark
.
std
::
size_t
num_embedded_bits
=
0
;
std
::
size_t
num_embedded_bits
=
0
;
std
::
size_t
block_index
=
1
;
// Without entry block.
std
::
size_t
block_index
=
1
;
// Without entry block.
...
@@ -161,10 +168,10 @@ namespace
...
@@ -161,10 +168,10 @@ namespace
for
(;
block_index
+
partition_opt
<
blocks
.
size
();
block_index
+=
partition_opt
)
for
(;
block_index
+
partition_opt
<
blocks
.
size
();
block_index
+=
partition_opt
)
{
{
//
W
atermark to embed.
//
Part of w
atermark to embed.
const
auto
data
=
(
watermark_opt
>>
(
bit_pos_
%
32
))
&
bit_mask
;
const
auto
data
=
(
watermark_opt
>>
(
bit_pos_
%
32
))
&
bit_mask
;
// Shuffle each `partition_opt` blocks.
// Shuffle
s
each `partition_opt` blocks.
for
(
std
::
size_t
i
=
0
;
i
<
partition_opt
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
partition_opt
;
i
++
)
{
{
const
auto
index
=
block_index
+
perm_table_
.
at
(
data
).
at
(
i
);
const
auto
index
=
block_index
+
perm_table_
.
at
(
data
).
at
(
i
);
...
@@ -178,7 +185,7 @@ namespace
...
@@ -178,7 +185,7 @@ namespace
bit_pos_
%=
32
;
bit_pos_
%=
32
;
}
}
// Insert rest blocks.
// Insert
s
rest blocks.
for
(;
block_index
<
blocks
.
size
();
block_index
++
)
for
(;
block_index
<
blocks
.
size
();
block_index
++
)
{
{
blocks
[
block_index
].
get
().
moveAfter
(
last_block
);
blocks
[
block_index
].
get
().
moveAfter
(
last_block
);
...
@@ -199,7 +206,7 @@ namespace
...
@@ -199,7 +206,7 @@ namespace
char
BlockWatermarkPass
::
ID
;
char
BlockWatermarkPass
::
ID
;
// Register pass.
// Register
s
pass.
const
llvm
::
RegisterPass
<
BlockWatermarkPass
>
pass_registry
=
const
llvm
::
RegisterPass
<
BlockWatermarkPass
>
pass_registry
=
{
{
"block-wm"
,
"block-wm"
,
...
...
src/nykk/pass/TestPass.cpp
View file @
d55e4b4d
...
@@ -85,7 +85,7 @@ namespace
...
@@ -85,7 +85,7 @@ namespace
return
false
;
return
false
;
}
}
// Swap 2nd and 3rd basic blocks.
// Swap
s
2nd and 3rd basic blocks.
llvm
::
BasicBlock
&
entry_bb
=
func
.
getEntryBlock
();
llvm
::
BasicBlock
&
entry_bb
=
func
.
getEntryBlock
();
llvm
::
BasicBlock
*
bb1
=
entry_bb
.
getNextNode
();
llvm
::
BasicBlock
*
bb1
=
entry_bb
.
getNextNode
();
llvm
::
BasicBlock
*
bb2
=
bb1
->
getNextNode
();
llvm
::
BasicBlock
*
bb2
=
bb1
->
getNextNode
();
...
@@ -98,7 +98,7 @@ namespace
...
@@ -98,7 +98,7 @@ namespace
char
TestPass
::
ID
;
char
TestPass
::
ID
;
// Register pass.
// Register
s
pass.
const
llvm
::
RegisterPass
<
TestPass
>
pass_registry
=
const
llvm
::
RegisterPass
<
TestPass
>
pass_registry
=
{
{
"testpass"
,
"testpass"
,
...
...
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