<commit_before>#include "firm.h"
#include "xmalloc.h"
#include "debug.h"

DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)

static int is_inside_loop(ir_node const *const node)
{
	ir_graph const *const graph = get_irn_irg(node);
	ir_node const *const block = is_Block(node) ? node : get_nodes_block(node);
	ir_loop const *const loop = get_irn_loop(block);
	return loop && loop != get_irg_loop(graph);
}

// insert a phi node between node and its nth predecessor in block
static ir_node *insert_phi(ir_node *const node, int const n, ir_node *const block)
{
	ir_node *const pred = get_irn_n(node, n);
	int const block_arity = get_irn_arity(block);
	ir_node **const in = ALLOCAN(ir_node *, block_arity);
	for (int i = 0; i < block_arity; ++i) {
		in[i] = pred;
	}
	ir_mode *const mode = get_irn_mode(pred);
	int opt = get_optimize();
	set_optimize(0);
	ir_node *const phi = new_r_Phi(block, block_arity, in, mode);
	set_optimize(opt);
	set_irn_n(node, n, phi);
	DB((dbg, LEVEL_3, "inserting phi %ld\n", get_irn_node_nr(phi)));
	return phi;
}

// insert phi nodes for the edge between node and its nth predecessor
static void insert_phis_for_edge(ir_node *node, int n)
{
	ir_node *const pred = get_irn_n(node, n);
	if (!mode_is_data(get_irn_mode(pred)))
		return;
	ir_node *const pred_block = get_nodes_block(pred);
	if (!is_inside_loop(pred_block))
		return;
	ir_node *block = get_nodes_block(node);
	ir_loop *loop = get_irn_loop(block);
	// walk up the dominance tree
	if (is_Phi(node)) {
		// if node is a phi, start the walk at the nth predecessor of block
		block = get_nodes_block(get_irn_n(block, n));
	}
	while (block != pred_block) {<commit_msg>mark newly added phi nodes as visited since we don't want to add phi nodes for the phi nodes we added<commit_after>#include "firm.h"
#include "xmalloc.h"
#include "debug.h"

DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)

static int is_inside_loop(ir_node const *const node)
{
	ir_graph const *const graph = get_irn_irg(node);
	ir_node const *const block = is_Block(node) ? node : get_nodes_block(node);
	ir_loop const *const loop = get_irn_loop(block);
	return loop && loop != get_irg_loop(graph);
}

// insert a phi node between node and its nth predecessor in block
static ir_node *insert_phi(ir_node *const node, int const n, ir_node *const block)
{
	ir_node *const pred = get_irn_n(node, n);
	int const block_arity = get_irn_arity(block);
	ir_node **const in = ALLOCAN(ir_node *, block_arity);
	for (int i = 0; i < block_arity; ++i) {
		in[i] = pred;
	}
	ir_mode *const mode = get_irn_mode(pred);
	int opt = get_optimize();
	set_optimize(0);
	ir_node *const phi = new_r_Phi(block, block_arity, in, mode);
	set_optimize(opt);
	set_irn_n(node, n, phi);
	mark_irn_visited(phi);
	DB((dbg, LEVEL_3, "inserting phi %ld\n", get_irn_node_nr(phi)));
	return phi;
}

// insert phi nodes for the edge between node and its nth predecessor
static void insert_phis_for_edge(ir_node *node, int n)
{
	ir_node *const pred = get_irn_n(node, n);
	if (!mode_is_data(get_irn_mode(pred)))
		return;
	ir_node *const pred_block = get_nodes_block(pred);
	if (!is_inside_loop(pred_block))
		return;
	ir_node *block = get_nodes_block(node);
	ir_loop *loop = get_irn_loop(block);
	// walk up the dominance tree
	if (is_Phi(node)) {
		// if node is a phi, start the walk at the nth predecessor of block
		block = get_nodes_block(get_irn_n(block, n));
	}
	while (block != pred_block) {
{'fraction_non_alphanumeric': 0.1195079086115993, 'fraction_numerical': 0.0017574692442882249, 'mean_word_length': 5.153153153153153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3656841', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1330, 'n_words': 373}