[Mesa-dev] [PATCH 2/2] i965/cfg: Ignore non-CF instructions in unreachable blocks.
Matt Turner
mattst88 at gmail.com
Wed Aug 17 18:54:29 UTC 2016
The basic block following a control flow structure like an infinite loop
will be unreachable. Ignore any non-control-flow instructions in it
since they can have no effect on the program.
Avoids a segmentation fault in cfg_t::intersect(a, b) when called on an
unreachable block. By avoiding ever putting code in an unreachable
block, we never attempt to optimize code in an unreachable block.
---
src/mesa/drivers/dri/i965/brw_cfg.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index 53b32be..2fa4e3d 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -312,6 +312,11 @@ cfg_t::cfg_t(exec_list *instructions)
break;
default:
+ if (cur->num != 0 && cur->parents.is_empty()) {
+ ip--;
+ continue;
+ }
+
cur->instructions.push_tail(inst);
break;
}
@@ -319,6 +324,12 @@ cfg_t::cfg_t(exec_list *instructions)
cur->end_ip = ip - 1;
+ /* If the last block was empty (because it was unreachable) drop it. */
+ if (cur->instructions.is_empty()) {
+ cur->link.remove();
+ num_blocks--;
+ }
+
make_block_array();
}
--
2.7.3
More information about the mesa-dev
mailing list