+/**
+ * Check the lifetime of locals in the given graph.
+ * Tail recursion can only be done, if we can prove that
+ * the lifetime of locals end with the recursive call.
+ * We do this by checking that no address of a local variable is
+ * stored or transmitted as an argument to a call.
+ *
+ * @return non-zero if it's ok to do tail recursion
+ */
+static int check_lifetime_of_locals(ir_graph *irg)
+{
+ ir_node *irg_frame = get_irg_frame(irg);
+ int i;
+
+ if (get_irg_outs_state(irg) != outs_consistent)
+ compute_irg_outs(irg);
+
+ for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) {
+ ir_node *succ = get_irn_out(irg_frame, i);
+
+ if (is_Sel(succ) && is_address_taken(succ))
+ return 0;
+ }
+ return 1;
+}
+