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
1ea3bab5
Commit
1ea3bab5
authored
Nov 15, 2018
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
テストパスを追加
parent
af1bb13f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
0 deletions
+151
-0
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+25
-0
TestPass.cpp
src/nykk/TestPass.cpp
+47
-0
TestPass.hpp
src/nykk/TestPass.hpp
+54
-0
fizzbuzz.c
test/fizzbuzz.c
+24
-0
No files found.
.gitignore
View file @
1ea3bab5
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
*.so
*.so
*.dll
*.dll
*.o
*.o
*.ll
Makefile
0 → 100644
View file @
1ea3bab5
CXX
:=
g++
CXXFLAGS
:=
\
-std
=
c++17
\
-Wall
\
-Wextra
\
-pedantic
\
-Werror
\
$(
shell
llvm-config-6.0
--cxxflags
)
LDFLAGS
:=
\
$(
shell
llvm-config-6.0
--ldflags
)
\
$(
shell
llvm-config-6.0
--libs
)
.PHONY
:
all clean
all
:
testpass.so
testpass.so
:
src/nykk/TestPass.o
${
CXX
}
${
CXXFLAGS
}
-shared
-o
$@
$<
${
LDFLAGS
}
src/nykk/TestPass.o
:
src/nykk/TestPass.cpp src/nykk/TestPass.hpp
clean
:
${
RM
}
*
.so src/
*
/
*
.o
src/nykk/TestPass.cpp
0 → 100644
View file @
1ea3bab5
#include "TestPass.hpp"
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/raw_ostream.h>
// Register pass.
llvm
::
RegisterPass
<
nykk
::
TestPass
>
g_test_pass
{
"testpass"
,
"Test pass"
,
};
namespace
nykk
{
// Pass id.
char
TestPass
::
ID
;
// Constructor of TestPass.
TestPass
::
TestPass
()
:
FunctionPass
(
ID
)
{
}
// Initialization before pass is run
bool
TestPass
::
doInitialization
(
llvm
::
Module
&
module
)
{
llvm
::
errs
()
<<
__FUNCTION__
<<
" : "
<<
module
.
getName
()
<<
"
\n
"
;
return
false
;
}
// Finalization after pass is run
bool
TestPass
::
doFinalization
(
llvm
::
Module
&
module
)
{
llvm
::
errs
()
<<
__FUNCTION__
<<
" : "
<<
module
.
getName
()
<<
"
\n
"
;
return
false
;
}
// Processes functions.
bool
TestPass
::
runOnFunction
(
llvm
::
Function
&
func
)
{
llvm
::
errs
()
<<
__FUNCTION__
<<
" : "
<<
func
.
getName
()
<<
"
\n
"
;
return
false
;
}
}
src/nykk/TestPass.hpp
0 → 100644
View file @
1ea3bab5
#ifndef INCLUDE_NYKK_TESTPASS_HPP
#define INCLUDE_NYKK_TESTPASS_HPP
#include <llvm/Pass.h>
namespace
nykk
{
class
TestPass
:
public
llvm
::
FunctionPass
{
public
:
static
char
ID
;
// For LLVM.
explicit
TestPass
();
// 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
;
/**
* @brief Finalization after pass is run.
*
* @param module Reference of the module.
*
* @return ?
*/
bool
doFinalization
(
llvm
::
Module
&
module
)
override
;
/**
* @brief Processes functions.
*
* @param func Reference to the function.
*
* @return `true` if the function was changed.
*/
bool
runOnFunction
(
llvm
::
Function
&
func
)
override
;
};
}
#endif
test/fizzbuzz.c
0 → 100644
View file @
1ea3bab5
#include <stdio.h>
int
main
(
void
)
{
for
(
int
i
=
1
;
i
<=
50
;
i
++
)
{
if
(
i
%
(
3
*
5
)
==
0
)
{
printf
(
"Fizz Buzz
\n
"
);
}
else
if
(
i
%
3
==
0
)
{
printf
(
"Fizz
\n
"
);
}
else
if
(
i
%
5
==
0
)
{
printf
(
"Buzz
\n
"
);
}
else
{
printf
(
"%d
\n
"
,
i
);
}
}
}
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