Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
eaef4d4c
Commit
eaef4d4c
authored
Feb 11, 2007
by
Christian Würdig
Browse files
added comment
added simple dead node elimination
parent
0279aba0
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/beirgmod.c
View file @
eaef4d4c
/**
* This file contains the following IRG modifications for be routines:
* - backend dominance information
* - SSA construction for a set of nodes
* - insertion of Perm nodes
* - empty block elimination
* - a simple dead node elimination (set inputs of unreachable nodes to BAD)
*
* Author: Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
* Date: 04.05.2005
* Copyright: (c) Universitaet Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
* CVS-Id: $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
...
...
@@ -706,3 +720,64 @@ int be_remove_empty_blocks(ir_graph *irg) {
}
return
changed
;
}
typedef
struct
_be_dead_out_env_t
{
ir_graph
*
irg
;
bitset_t
*
reachable
;
DEBUG_ONLY
(
firm_dbg_module_t
*
dbg
);
}
be_dead_out_env_t
;
/**
* Check if @p node has dead users, i.e. they are reachable only via outedges from @p node.
* Set all ins of those users to BAD.
*/
static
void
kill_dead_out
(
ir_node
*
node
,
be_dead_out_env_t
*
env
)
{
ir_graph
*
irg
=
env
->
irg
;
const
ir_edge_t
*
edge
,
*
tmp_edge
;
if
(
irn_visited
(
node
))
return
;
mark_irn_visited
(
node
);
/* check all out edges */
foreach_out_edge_safe
(
node
,
edge
,
tmp_edge
)
{
ir_node
*
src
=
get_edge_src_irn
(
edge
);
if
(
!
bitset_is_set
(
env
->
reachable
,
get_irn_idx
(
src
)))
{
/* BEWARE: do not kill anchors or TLS */
if
(
src
!=
get_irg_globals
(
irg
)
&&
src
!=
get_irg_tls
(
irg
))
{
DBG
((
env
->
dbg
,
LEVEL_1
,
"killing %+F, only reachable from %+F
\n
"
,
src
,
node
));
be_kill_node
(
src
);
}
continue
;
}
/* descent */
if
(
!
is_Block
(
src
))
{
kill_dead_out
(
src
,
env
);
}
}
}
static
void
set_reachable
(
ir_node
*
node
,
void
*
data
)
{
bitset_t
*
reachable
=
data
;
bitset_set
(
reachable
,
get_irn_idx
(
node
));
}
/**
* Set input of all nodes only reachable via out edges to BAD.
*/
void
be_kill_dead_nodes
(
ir_graph
*
irg
)
{
be_dead_out_env_t
env
;
env
.
irg
=
irg
;
env
.
reachable
=
bitset_alloca
(
get_irg_last_idx
(
irg
));
FIRM_DBG_REGISTER
(
env
.
dbg
,
"firm.be.killdead"
);
/* collect all reachable nodes */
irg_walk_in_or_dep_graph
(
irg
,
set_reachable
,
NULL
,
env
.
reachable
);
/* this is a forward walk (start -> end) */
inc_irg_visited
(
irg
);
kill_dead_out
(
get_irg_start
(
irg
),
&
env
);
}
ir/be/beirgmod.h
View file @
eaef4d4c
/**
* IRG modifications for be routines.
* @date 4.5.2005
* This file contains the following IRG modifications for be routines:
* - backend dominance information
* - SSA construction for a set of nodes
* - insertion of Perm nodes
* - empty block elimination
* - a simple dead node elimination (set inputs of unreachable nodes to BAD)
*
* Copyright (C) 2005 Universitaet Karlsruhe.
* Released under the GPL.
* Author: Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
* Date: 04.05.2005
* Copyright: (c) Universitaet Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
* CVS-Id: $Id$
*/
#ifndef _BEIRGMOD_H
...
...
@@ -130,4 +136,10 @@ void extreme_liverange_splitting(struct _be_chordal_env_t *cenv);
*/
int
be_remove_empty_blocks
(
ir_graph
*
irg
);
/**
* Set input of all nodes only reachable via out edges to BAD.
* @param irg The irg to check.
*/
void
be_kill_dead_nodes
(
ir_graph
*
irg
);
#endif
/* _BEIRGMOD_H */
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