diff options
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r-- | mesalib/src/glsl/ir_validate.cpp | 33 | ||||
-rw-r--r-- | mesalib/src/glsl/link_functions.cpp | 8 | ||||
-rw-r--r-- | mesalib/src/glsl/opt_function_inlining.cpp | 7 |
3 files changed, 42 insertions, 6 deletions
diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index 44d7549ea..b2ae08f37 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -70,6 +70,7 @@ public: virtual ir_visitor_status visit_leave(ir_swizzle *ir); virtual ir_visitor_status visit_enter(ir_assignment *ir); + virtual ir_visitor_status visit_enter(ir_call *ir); static void validate_ir(ir_instruction *ir, void *data); @@ -173,6 +174,19 @@ ir_validate::visit_enter(ir_function *ir) this->validate_ir(ir, this->data); + /* Verify that all of the things stored in the list of signatures are, + * in fact, function signatures. + */ + foreach_list(node, &ir->signatures) { + ir_instruction *sig = (ir_instruction *) node; + + if (sig->ir_type != ir_type_function_signature) { + printf("Non-signature in signature list of function `%s'\n", + ir->name); + abort(); + } + } + return visit_continue; } @@ -198,6 +212,12 @@ ir_validate::visit_enter(ir_function_signature *ir) abort(); } + if (ir->return_type == NULL) { + printf("Function signature %p for function %s has NULL return type.\n", + ir, ir->function_name()); + abort(); + } + this->validate_ir(ir, this->data); return visit_continue; @@ -488,6 +508,19 @@ ir_validate::visit_enter(ir_assignment *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit_enter(ir_call *ir) +{ + ir_function_signature *const callee = ir->get_callee(); + + if (callee->ir_type != ir_type_function_signature) { + printf("IR called by ir_call is not ir_function_signature!\n"); + abort(); + } + + return visit_continue; +} + void ir_validate::validate_ir(ir_instruction *ir, void *data) { diff --git a/mesalib/src/glsl/link_functions.cpp b/mesalib/src/glsl/link_functions.cpp index 5851c14d6..ae8818be8 100644 --- a/mesalib/src/glsl/link_functions.cpp +++ b/mesalib/src/glsl/link_functions.cpp @@ -99,9 +99,15 @@ public: * details that may be missing. */ ir_function *f = linked->symbols->get_function(name); - if (f == NULL) + if (f == NULL) { f = new(linked) ir_function(name); + /* Add the new function to the linked IR. + */ + linked->symbols->add_function(f); + linked->ir->push_head(f); + } + ir_function_signature *linked_sig = f->exact_matching_signature(&callee->parameters); if (linked_sig == NULL) { diff --git a/mesalib/src/glsl/opt_function_inlining.cpp b/mesalib/src/glsl/opt_function_inlining.cpp index 2e7831dcb..8fef358cc 100644 --- a/mesalib/src/glsl/opt_function_inlining.cpp +++ b/mesalib/src/glsl/opt_function_inlining.cpp @@ -126,7 +126,7 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters = new ir_variable *[num_parameters]; /* Generate storage for the return value. */ - if (this->callee->return_type) { + if (!this->callee->return_type->is_void()) { retval = new(ctx) ir_variable(this->callee->return_type, "_ret_val", ir_var_auto); next_ir->insert_before(retval); @@ -209,10 +209,7 @@ ir_call::generate_inline(ir_instruction *next_ir) } /* Now push those new instructions in. */ - foreach_iter(exec_list_iterator, iter, new_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - next_ir->insert_before(ir); - } + next_ir->insert_before(&new_instructions); /* Copy back the value of any 'out' parameters from the function body * variables to our own. |