Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
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
wenyuanbo
tic
Commits
0c9adc5b
Commit
0c9adc5b
authored
Sep 08, 2017
by
Tianqi Chen
Committed by
GitHub
Sep 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LLVM] Protect ll when emit pass (#436)
parent
edca6830
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
src/codegen/llvm/codegen_nvptx.cc
+4
-2
src/codegen/llvm/llvm_common.h
+1
-0
src/codegen/llvm/llvm_module.cc
+4
-2
No files found.
src/codegen/llvm/codegen_nvptx.cc
View file @
0c9adc5b
...
...
@@ -147,14 +147,16 @@ runtime::Module BuildNVPTX(Array<LoweredFunc> funcs, std::string target) {
llvm
::
raw_svector_ostream
dest_ptx
(
data_ptx
),
dest_ll
(
data_ll
);
dest_ptx
.
SetUnbuffered
();
dest_ll
.
SetUnbuffered
();
// print ll
module
->
print
(
dest_ll
,
nullptr
);
std
::
string
ll
(
data_ll
.
begin
(),
data_ll
.
end
());
// emit ptx
llvm
::
legacy
::
PassManager
pass
;
CHECK
(
tm
->
addPassesToEmitFile
(
pass
,
dest_ptx
,
llvm
::
TargetMachine
::
CGFT_AssemblyFile
)
==
0
)
<<
"Cannot emit target CGFT_ObjectFile"
;
pass
.
run
(
*
module
);
module
->
print
(
dest_ll
,
nullptr
);
std
::
string
ptx
(
data_ptx
.
begin
(),
data_ptx
.
end
());
std
::
string
ll
(
data_ll
.
begin
(),
data_ll
.
end
());
return
CUDAModuleCreate
(
ptx
,
"ptx"
,
ExtractFuncInfo
(
funcs
),
ll
);
}
...
...
src/codegen/llvm/llvm_common.h
View file @
0c9adc5b
...
...
@@ -28,6 +28,7 @@
#include <llvm/IR/MDBuilder.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#include <llvm/Transforms/IPO.h>
...
...
src/codegen/llvm/llvm_module.cc
View file @
0c9adc5b
...
...
@@ -68,19 +68,21 @@ class LLVMModuleNode final : public runtime::ModuleNode {
CHECK_EQ
(
ecode
.
value
(),
0
)
<<
"Cannot open file: "
<<
file_name
<<
" "
<<
ecode
.
message
();
if
(
fmt
==
"o"
||
fmt
==
"obj"
)
{
std
::
unique_ptr
<
llvm
::
Module
>
m
=
llvm
::
CloneModule
(
mptr_
);
llvm
::
legacy
::
PassManager
pass
;
CHECK
(
tm_
);
CHECK
(
tm_
->
addPassesToEmitFile
(
pass
,
dest
,
llvm
::
TargetMachine
::
CGFT_ObjectFile
)
==
0
)
<<
"Cannot emit target CGFT_ObjectFile"
;
pass
.
run
(
*
m
ptr_
);
pass
.
run
(
*
m
);
}
else
if
(
fmt
==
"s"
||
fmt
==
"asm"
)
{
std
::
unique_ptr
<
llvm
::
Module
>
m
=
llvm
::
CloneModule
(
mptr_
);
llvm
::
legacy
::
PassManager
pass
;
CHECK
(
tm_
);
CHECK
(
tm_
->
addPassesToEmitFile
(
pass
,
dest
,
llvm
::
TargetMachine
::
CGFT_AssemblyFile
)
==
0
)
<<
"Cannot emit target CGFT_AssemblyFile"
;
pass
.
run
(
*
m
ptr_
);
pass
.
run
(
*
m
);
}
else
if
(
fmt
==
"ll"
)
{
mptr_
->
print
(
dest
,
nullptr
);
}
else
if
(
fmt
==
"bc"
)
{
...
...
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