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
19e1b6d8
Commit
19e1b6d8
authored
Apr 11, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Apr 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some refcount-pass microoptimizations
parent
0aa99fe6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+2
-2
src/codegen/irgen/refcounts.cpp
src/codegen/irgen/refcounts.cpp
+16
-11
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
19e1b6d8
...
...
@@ -3126,7 +3126,7 @@ std::tuple<llvm::Value*, llvm::Value*, llvm::Value*> createLandingpad(llvm::Basi
llvm
::
IRBuilder
<
true
>
builder
(
bb
);
llvm
::
Function
*
_personality_func
=
g
.
stdlib_module
->
getFunction
(
"__gxx_personality_v0"
);
static
llvm
::
Function
*
_personality_func
=
g
.
stdlib_module
->
getFunction
(
"__gxx_personality_v0"
);
assert
(
_personality_func
);
llvm
::
Value
*
personality_func
=
g
.
cur_module
->
getOrInsertFunction
(
_personality_func
->
getName
(),
_personality_func
->
getFunctionType
());
...
...
@@ -3137,7 +3137,7 @@ std::tuple<llvm::Value*, llvm::Value*, llvm::Value*> createLandingpad(llvm::Basi
llvm
::
Value
*
cxaexc_pointer
=
builder
.
CreateExtractValue
(
landing_pad
,
{
0
});
llvm
::
Function
*
std_module_catch
=
g
.
stdlib_module
->
getFunction
(
"__cxa_begin_catch"
);
static
llvm
::
Function
*
std_module_catch
=
g
.
stdlib_module
->
getFunction
(
"__cxa_begin_catch"
);
auto
begin_catch_func
=
g
.
cur_module
->
getOrInsertFunction
(
std_module_catch
->
getName
(),
std_module_catch
->
getFunctionType
());
assert
(
begin_catch_func
);
...
...
src/codegen/irgen/refcounts.cpp
View file @
19e1b6d8
...
...
@@ -787,7 +787,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
}
if
(
successors
.
size
())
{
std
::
vector
<
llvm
::
Value
*>
tracked_values
;
std
::
unordered_s
et
<
llvm
::
Value
*>
in_tracked_values
;
llvm
::
DenseS
et
<
llvm
::
Value
*>
in_tracked_values
;
for
(
auto
SBB
:
successors
)
{
// errs() << "DETERMINISM: successor " << SBB->getName() << '\n';
assert
(
states
.
count
(
SBB
));
...
...
@@ -801,6 +801,11 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
}
}
llvm
::
SmallVector
<
std
::
pair
<
BlockMap
*
,
llvm
::
BasicBlock
*>
,
4
>
successor_info
;
for
(
auto
SBB
:
successors
)
{
successor_info
.
emplace_back
(
&
states
[
SBB
].
ending_refs
,
SBB
);
}
// size_t hash = 0;
for
(
auto
v
:
tracked_values
)
{
// hash = hash * 31 + std::hash<llvm::StringRef>()(v->getName());
...
...
@@ -808,12 +813,11 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
const
auto
refstate
=
rt
->
vars
.
lookup
(
v
);
int
min_refs
=
1000000000
;
for
(
auto
SBB
:
successors
)
{
auto
&&
ending_refs
=
states
[
SBB
].
ending_refs
;
if
(
ending_refs
.
count
(
v
))
{
for
(
auto
&&
s_info
:
successor_info
)
{
if
(
s_info
.
first
->
count
(
v
))
{
// llvm::outs() << "Going from " << BB.getName() << " to " << SBB->getName() << ", have "
//<< it->second << " refs on " << *v << '\n';
min_refs
=
std
::
min
(
ending_refs
[
v
],
min_refs
);
min_refs
=
std
::
min
(
(
*
s_info
.
first
)
[
v
],
min_refs
);
}
else
{
// llvm::outs() << "Going from " << BB.getName() << " to " << SBB->getName()
//<< ", have 0 (missing) refs on " << *v << '\n';
...
...
@@ -824,19 +828,20 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
if
(
refstate
.
reftype
==
RefType
::
OWNED
)
min_refs
=
std
::
max
(
1
,
min_refs
);
for
(
auto
SBB
:
successors
)
{
for
(
auto
&&
s_info
:
successor_info
)
{
int
this_refs
=
0
;
auto
&&
ending_refs
=
states
[
SBB
].
ending_refs
;
if
(
ending_refs
.
count
(
v
))
this_refs
=
ending_refs
[
v
];
if
(
s_info
.
first
->
count
(
v
))
this_refs
=
(
*
s_info
.
first
)[
v
];
if
(
this_refs
>
min_refs
)
{
// llvm::outs() << "Going from " << BB.getName() << " to " << SBB->getName() << ", need to add "
//<< (this_refs - min_refs) << " refs to " << *v << '\n';
state
.
increfs
.
push_back
(
RefOp
({
v
,
refstate
.
nullable
,
this_refs
-
min_refs
,
NULL
,
SBB
,
bb
}));
state
.
increfs
.
push_back
(
RefOp
({
v
,
refstate
.
nullable
,
this_refs
-
min_refs
,
NULL
,
s_info
.
second
,
bb
}));
}
else
if
(
this_refs
<
min_refs
)
{
assert
(
refstate
.
reftype
==
RefType
::
OWNED
);
state
.
decrefs
.
push_back
(
RefOp
({
v
,
refstate
.
nullable
,
min_refs
-
this_refs
,
NULL
,
SBB
,
bb
}));
state
.
decrefs
.
push_back
(
RefOp
({
v
,
refstate
.
nullable
,
min_refs
-
this_refs
,
NULL
,
s_info
.
second
,
bb
}));
}
}
...
...
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