Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
d4aaa88a
Commit
d4aaa88a
authored
Feb 23, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes
parent
4ae8f9b7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
9 deletions
+32
-9
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+6
-3
src/codegen/irgen/refcounts.cpp
src/codegen/irgen/refcounts.cpp
+23
-6
src/codegen/irgen/util.cpp
src/codegen/irgen/util.cpp
+3
-0
No files found.
src/codegen/irgen.cpp
View file @
d4aaa88a
...
...
@@ -863,10 +863,13 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
Value
*
val
=
v
->
getValue
();
llvm_phi
->
addIncoming
(
v
->
getValue
(),
llvm_exit_blocks
[
b
->
predecessors
[
j
]]);
if
(
v
->
getType
()
->
getBoxType
()
==
v
->
getType
())
{
llvm
::
outs
()
<<
*
v
->
getValue
()
<<
" is getting consumed by phi "
<<
*
llvm_phi
<<
'\n'
;
irstate
->
getRefcounts
()
->
setType
(
llvm_phi
,
RefType
::
OWNED
);
assert
(
llvm
::
isa
<
llvm
::
BranchInst
>
(
llvm_exit_blocks
[
b
->
predecessors
[
j
]]
->
getTerminator
()));
irstate
->
getRefcounts
()
->
refConsumed
(
v
->
getValue
(),
llvm_exit_blocks
[
b
->
predecessors
[
j
]]
->
getTerminator
());
}
}
if
(
this_is_osr_entry
)
{
assert
(
0
&&
"check refcounting"
);
...
...
src/codegen/irgen/refcounts.cpp
View file @
d4aaa88a
...
...
@@ -43,6 +43,8 @@
namespace
pyston
{
llvm
::
Value
*
RefcountTracker
::
setType
(
llvm
::
Value
*
v
,
RefType
reftype
)
{
assert
(
!
llvm
::
isa
<
llvm
::
UndefValue
>
(
v
));
auto
&
var
=
this
->
vars
[
v
];
assert
(
var
.
reftype
==
reftype
||
var
.
reftype
==
RefType
::
UNKNOWN
);
...
...
@@ -245,14 +247,15 @@ class BlockOrderer {
private:
llvm
::
DenseMap
<
llvm
::
BasicBlock
*
,
int
>
priority
;
// lower goes first
class
BlockComparer
{
struct
BlockComparer
{
bool
operator
()(
std
::
pair
<
llvm
::
BasicBlock
*
,
int
>
lhs
,
std
::
pair
<
llvm
::
BasicBlock
*
,
int
>
rhs
)
{
return
lhs
.
second
<
rhs
.
second
;
return
lhs
.
second
>
rhs
.
second
;
}
};
llvm
::
DenseSet
<
llvm
::
BasicBlock
*>
in_queue
;
std
::
priority_queue
<
std
::
pair
<
llvm
::
BasicBlock
*
,
int
>>
queue
;
std
::
priority_queue
<
std
::
pair
<
llvm
::
BasicBlock
*
,
int
>
,
std
::
vector
<
std
::
pair
<
llvm
::
BasicBlock
*
,
int
>>
,
BlockComparer
>
queue
;
public:
BlockOrderer
(
std
::
vector
<
llvm
::
BasicBlock
*>
order
)
{
...
...
@@ -262,6 +265,7 @@ public:
}
void
add
(
llvm
::
BasicBlock
*
b
)
{
assert
(
in_queue
.
size
()
==
queue
.
size
());
if
(
in_queue
.
count
(
b
))
return
;
assert
(
priority
.
count
(
b
));
...
...
@@ -416,6 +420,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
}
#endif
llvm
::
outs
()
<<
'\n'
;
llvm
::
outs
()
<<
"Processing "
<<
BB
.
getName
()
<<
'\n'
;
RefState
&
state
=
states
[
&
BB
];
...
...
@@ -484,6 +489,13 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
// Then, iterate backwards through the instructions in this BB, updating the ref states
for
(
auto
&
I
:
llvm
::
iterator_range
<
llvm
::
BasicBlock
::
reverse_iterator
>
(
BB
.
rbegin
(),
BB
.
rend
()))
{
// Phis get special handling:
// - we only use one of the operands to the phi node (based on the block we came from)
// - the phi-node-generator is supposed to handle that by putting a refConsumed on the terminator of the previous block
// - that refConsumed will caus a use as well.
if
(
llvm
::
isa
<
llvm
::
PHINode
>
(
&
I
))
continue
;
llvm
::
DenseMap
<
llvm
::
Value
*
,
int
>
num_consumed_by_inst
;
llvm
::
DenseMap
<
llvm
::
Value
*
,
int
>
num_times_as_op
;
...
...
@@ -536,6 +548,8 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
}
}
llvm
::
outs
()
<<
"End of "
<<
BB
.
getName
()
<<
'\n'
;
// Handle variables that were defined in this BB:
for
(
auto
&&
p
:
rt
->
vars
)
{
llvm
::
Instruction
*
inst
=
llvm
::
dyn_cast
<
llvm
::
Instruction
>
(
p
.
first
);
...
...
@@ -568,9 +582,9 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
for
(
auto
&&
p
:
state
.
ending_refs
)
{
assert
(
p
.
second
);
// Anything left should either be an argument
or a
global variable
// Anything left should either be an argument
, constant or
global variable
#ifndef NDEBUG
if
(
!
llvm
::
isa
<
llvm
::
GlobalVariable
>
(
p
.
first
))
{
if
(
!
llvm
::
isa
<
llvm
::
GlobalVariable
>
(
p
.
first
)
&&
!
llvm
::
isa
<
llvm
::
Constant
>
(
p
.
first
)
)
{
bool
found
=
false
;
for
(
auto
&&
arg
:
f
->
args
())
{
if
(
&
arg
==
p
.
first
)
{
...
...
@@ -578,6 +592,8 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
break
;
}
}
if
(
!
found
)
llvm
::
outs
()
<<
"Couldn't find "
<<
*
p
.
first
<<
'\n'
;
assert
(
found
);
}
#endif
...
...
@@ -590,7 +606,8 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
if
(
endingRefsDifferent
(
orig_ending_refs
,
state
.
ending_refs
))
{
llvm
::
outs
()
<<
"changed!
\n
"
;
for
(
auto
&&
SBB
:
llvm
::
successors
(
&
BB
))
{
for
(
auto
&&
SBB
:
llvm
::
predecessors
(
&
BB
))
{
// llvm::outs() << "reconsidering: " << SBB->getName() << '\n';
orderer
.
add
(
SBB
);
}
}
else
{
...
...
src/codegen/irgen/util.cpp
View file @
d4aaa88a
...
...
@@ -245,6 +245,9 @@ public:
};
void
dumpPrettyIR
(
llvm
::
Function
*
f
)
{
//f->getParent()->dump();
//return;
std
::
unique_ptr
<
llvm
::
Module
>
tmp_module
(
llvm
::
CloneModule
(
f
->
getParent
()));
// std::unique_ptr<llvm::Module> tmp_module(new llvm::Module("tmp", g.context));
...
...
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