Review: compiler failed to mark a const as "not written" (issue195084)


larry...@...
 

Reviewers: ,

Description:
Bug fix:

When a function's 'return' statement is not the last statement in the
function body, we use a trick where we wrap the function in a 'do { ...
} while (0)' and the return is like a 'break'. (This is because we
don't have a true jump instruction, which is a pain for SIMD.) We say
'while 0' because we don't want to LOOP, we just want a loop to jump out
of, if you catch my drift.

The bug is that I made the "0" a true constant, but forgot to mark that
the while condition was not written by the while statement itself, and
therefore got a "can't write to a constant" error later on.


Please review this at http://codereview.appspot.com/195084/show

Affected files:
src/liboslcomp/codegen.cpp


Index: src/liboslcomp/codegen.cpp
===================================================================
--- src/liboslcomp/codegen.cpp (revision 552)
+++ src/liboslcomp/codegen.cpp (working copy)
@@ -1181,7 +1181,8 @@
Symbol *condvar = m_compiler->make_constant (0);
size_t argstart = m_compiler->add_op_args (1, &condvar);
m_compiler->ircode(loop_op).set_args (argstart, 1);
- m_compiler->ircode(loop_op).argread (0, true); // read also
+ m_compiler->ircode(loop_op).argread (0, true); // read
+ m_compiler->ircode(loop_op).argwrite (0, false); // not written
int endlabel = m_compiler->next_op_label ();
m_compiler->ircode(loop_op).set_jump (startlabel, startlabel,
endlabel, endlabel);

Join osl-dev@lists.aswf.io to automatically receive all group messages.