Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
peephole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
peephole
Commits
d3dfaa10
Commit
d3dfaa10
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added dummy block to prevent DCE in library fucntion calls.
parent
5c33f2be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dataflow.py
+18
-3
18 additions, 3 deletions
src/dataflow.py
src/liveness.py
+5
-0
5 additions, 0 deletions
src/liveness.py
with
23 additions
and
3 deletions
src/dataflow.py
+
18
−
3
View file @
d3dfaa10
...
...
@@ -2,7 +2,7 @@ from statement import Block
class
BasicBlock
(
Block
):
def
__init__
(
self
,
statements
=
[]):
def
__init__
(
self
,
statements
=
[]
,
dummy
=
False
):
Block
.
__init__
(
self
,
statements
)
self
.
edges_to
=
[]
self
.
edges_from
=
[]
...
...
@@ -10,6 +10,8 @@ class BasicBlock(Block):
self
.
dominates
=
[]
self
.
dominated_by
=
[]
self
.
dummy
=
dummy
def
add_edge_to
(
self
,
block
):
if
block
not
in
self
.
edges_to
:
self
.
edges_to
.
append
(
block
)
...
...
@@ -58,13 +60,18 @@ def find_basic_blocks(statements):
blocks
.
append
(
BasicBlock
(
statements
[
leaders
[
-
1
]:]))
# Add a target block for unknown jump targets
blocks
.
append
(
BasicBlock
([],
dummy
=
True
))
return
blocks
def
generate_flow_graph
(
blocks
):
"""
Add flow graph edge administration of an ordered sequence of basic
blocks.
"""
for
i
,
b
in
enumerate
(
blocks
):
dummy_block
=
blocks
[
-
1
]
for
i
,
b
in
enumerate
(
blocks
[:
-
1
]):
last_statement
=
b
[
-
1
]
if
last_statement
.
is_jump
():
...
...
@@ -72,9 +79,17 @@ def generate_flow_graph(blocks):
# Compare the target to all leading labels, add an edge if the
# label matches the jump target
for
other
in
blocks
:
target_found
=
False
for
other
in
blocks
[:
-
1
]:
if
other
[
0
].
is_label
(
target
):
b
.
add_edge_to
(
other
)
target_found
=
True
# If the jump target is outside the program, add an edge to the
# dummy block
if
not
target_found
:
b
.
add_edge_to
(
dummy_block
)
# A branch and jump-and-line instruction also creates an edge to
# the next block
...
...
This diff is collapsed.
Click to expand it.
src/liveness.py
+
5
−
0
View file @
d3dfaa10
...
...
@@ -28,6 +28,11 @@ def create_use_def(block):
used
=
set
()
defined
=
set
()
if
block
.
dummy
:
block
.
use_set
=
set
([
'
$4
'
,
'
$5
'
,
'
$6
'
,
'
$7
'
])
block
.
def_set
=
set
([
'
$2
'
,
'
$3
'
])
return
# Get the last of each definition series and put in in the `def' set
block
.
use_set
=
set
()
block
.
def_set
=
set
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment