[Mesa-dev] [PATCH] i965/fs: Check for compilation failure and bail before optimizing.

Kenneth Graunke kenneth at whitecape.org
Fri Jun 10 22:51:05 PDT 2011


Prior to this patch, it would attempt to optimize and allocate registers
for the program even if it failed to compile.  This seems wasteful.

More importantly, the "message length > 11" failure seems to choke the
instruction scheduler, making it somehow use an undefined value and
segmentation fault.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Eric,

Yeah.  Somehow I wasn't thinking straight and thought that'd check for
failure after every instruction.  But it doesn't; those are only the
top-level variable declarations and functions.  No sense in that at all.

This version moves it below the loop---after the bulk of codegen, but
prior to optimizing and register allocation.  Seems reasonable.

The 16-element stack array theory sounds about right.  Presumably we
should never run into that limit for good code, and this ought to reject
the bad code.

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 7c73a8f..3a16afe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1533,6 +1533,8 @@ fs_visitor::run()
 	 this->result = reg_undef;
 	 ir->accept(this);
       }
+      if (failed)
+	 return false;
 
       emit_fb_writes();
 
-- 
1.7.5.4



More information about the mesa-dev mailing list