From: Ian Romanick Date: Mon, 7 Mar 2011 23:13:06 +0000 (-0800) Subject: glsl: Add several function / call related validations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8bbfbb14eee53e42a488ba24c0cfc9ffa1cf6318;p=mesa.git glsl: Add several function / call related validations The signature list in a function must contain only ir_function_signature nodes. The target of an ir_call must be an ir_function_signature. These were added while trying to debug Mesa bugzilla #34203. --- diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 5e491db2c41..b2ae08f3777 100644 --- a/src/glsl/ir_validate.cpp +++ b/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; } @@ -494,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) {