libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Bad node

Bad nodes indicate invalid input, which is values which should never be computed. More...

Functions

ir_nodenew_rd_Bad (dbg_info *dbgi, ir_graph *irg, ir_mode *mode)
 Construct a Bad node. More...
 
ir_nodenew_r_Bad (ir_graph *irg, ir_mode *mode)
 Construct a Bad node. More...
 
ir_nodenew_d_Bad (dbg_info *dbgi, ir_mode *mode)
 Construct a Bad node. More...
 
ir_nodenew_Bad (ir_mode *mode)
 Construct a Bad node. More...
 
int is_Bad (const ir_node *node)
 Test if node is a Bad. More...
 
ir_opget_op_Bad (void)
 Returns opcode for Bad nodes. More...
 

Variables

ir_opop_Bad
 Bad opcode. More...
 

Detailed Description

Bad nodes indicate invalid input, which is values which should never be computed.

The typical use case for the Bad node is removing unreachable code. Frontends should set the current_block to Bad when it is clear that following code must be unreachable (ie. after a goto or return statement). Optimizations also set block predecessors to Bad when it becomes clear, that a control flow edge can never be executed.

The gigo optimizations ensures that nodes with Bad as their block, get replaced by Bad themselves. Nodes with at least 1 Bad input get exchanged with Bad too. Exception to this rule are Block, Phi, Tuple and End node; This is because removing inputs from a Block is hairy operation (requiring, Phis to be shortened too for example). So instead of removing block inputs they are set to Bad, and the actual removal is left to the control flow optimization phase. Block, Phi, Tuple with only Bad inputs however are replaced by Bad right away.

In the future we may use the Bad node to model poison values that arise from undefined behaviour like reading uninitialized local variables in C.

Function Documentation

ir_op* get_op_Bad ( void  )

Returns opcode for Bad nodes.

Definition at line 414 of file gen_irnode.c.

References op_Bad.

int is_Bad ( const ir_node node)

Test if node is a Bad.

Returns
1 if the node is a Bad node, 0 otherwise

Definition at line 3004 of file gen_irnode.c.

ir_node* new_Bad ( ir_mode mode)

Construct a Bad node.

Parameters
modemode of the operations result

Definition at line 409 of file gen_irnode.c.

References new_d_Bad().

ir_node* new_d_Bad ( dbg_info dbgi,
ir_mode mode 
)

Construct a Bad node.

Parameters
dbgiA pointer to debug information.
modemode of the operations result

Definition at line 402 of file gen_irnode.c.

References current_ir_graph, IR_GRAPH_CONSTRAINT_CONSTRUCTION, irg_is_constrained(), and new_rd_Bad().

Referenced by new_Bad().

ir_node* new_r_Bad ( ir_graph irg,
ir_mode mode 
)

Construct a Bad node.

Parameters
irgThe IR graph the node belongs to.
modemode of the operations result

Definition at line 397 of file gen_irnode.c.

References new_rd_Bad().

ir_node* new_rd_Bad ( dbg_info dbgi,
ir_graph irg,
ir_mode mode 
)

Construct a Bad node.

Parameters
dbgiA pointer to debug information.
irgThe IR graph the node belongs to.
modemode of the operations result

Definition at line 384 of file gen_irnode.c.

References get_irg_start_block(), new_ir_node(), op_Bad, optimize_node(), and verify_new_node().

Referenced by new_d_Bad(), and new_r_Bad().

Variable Documentation

ir_op* op_Bad

Bad opcode.

Definition at line 672 of file nodes.h.

Referenced by get_op_Bad(), and new_rd_Bad().