summaryrefslogtreecommitdiff
path: root/ir_function_inlining.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-06-24 15:13:03 -0700
committerEric Anholt <eric@anholt.net>2010-06-24 15:13:03 -0700
commite33c10328caec29616a5433b1d1df9088f3a84df (patch)
tree723cc38803bb10032d28be9a9a161232d05d0fd1 /ir_function_inlining.cpp
parent9290e0dd28e646c3dc810e0a6405582f8bf643b6 (diff)
parent26bbfb7917a71d46d9227bbf960606cb673636d3 (diff)
Merge remote branch 'cworth/master'
Conflicts: ast_to_hir.cpp ir.cpp This brings in the talloc-based memory management work, so that the compiler (almost) no longer leaks memory.
Diffstat (limited to 'ir_function_inlining.cpp')
-rw-r--r--ir_function_inlining.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp
index 851c0dd9f7..e55780c940 100644
--- a/ir_function_inlining.cpp
+++ b/ir_function_inlining.cpp
@@ -94,13 +94,14 @@ do_function_inlining(exec_list *instructions)
static void
replace_return_with_assignment(ir_instruction *ir, void *data)
{
+ void *ctx = talloc_parent(ir);
ir_variable *retval = (ir_variable *)data;
ir_return *ret = ir->as_return();
if (ret) {
if (ret->value) {
- ir_rvalue *lhs = new ir_dereference_variable(retval);
- ret->insert_before(new ir_assignment(lhs, ret->value, NULL));
+ ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval);
+ ret->insert_before(new(ctx) ir_assignment(lhs, ret->value, NULL));
ret->remove();
} else {
/* un-valued return has to be the last return, or we shouldn't
@@ -114,6 +115,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data)
ir_rvalue *
ir_call::generate_inline(ir_instruction *next_ir)
{
+ void *ctx = talloc_parent(this);
ir_variable **parameters;
int num_parameters;
int i;
@@ -130,7 +132,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
/* Generate storage for the return value. */
if (this->callee->return_type) {
- retval = new ir_variable(this->callee->return_type, "__retval");
+ retval = new(ctx) ir_variable(this->callee->return_type, "__retval");
next_ir->insert_before(retval);
}
@@ -154,8 +156,8 @@ ir_call::generate_inline(ir_instruction *next_ir)
sig_param->mode == ir_var_inout) {
ir_assignment *assign;
- assign = new ir_assignment(new ir_dereference_variable(parameters[i]),
- param, NULL);
+ assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
+ param, NULL);
next_ir->insert_before(assign);
}
@@ -185,9 +187,9 @@ ir_call::generate_inline(ir_instruction *next_ir)
parameters[i]->mode == ir_var_inout) {
ir_assignment *assign;
- assign = new ir_assignment(param->as_rvalue(),
- new ir_dereference_variable(parameters[i]),
- NULL);
+ assign = new(ctx) ir_assignment(param->as_rvalue(),
+ new(ctx) ir_dereference_variable(parameters[i]),
+ NULL);
next_ir->insert_before(assign);
}
@@ -199,7 +201,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
hash_table_dtor(ht);
if (retval)
- return new ir_dereference_variable(retval);
+ return new(ctx) ir_dereference_variable(retval);
else
return NULL;
}