Improve redundant trace_var elimination.

Previously, we would avoid emitting redundant trace_vars by checking to
see if the slot is being assigned to the exact same Var.ID. However,
this had the potential to eliminate useful trace_vars:

- At the start of execution, slots all contain 0. Code which explicitly
  assigned a zero into a slot would not be shown in a trace. (So things
  like `color = half4(0,1,0,1)` would only emit traces for color.ga.)
- A function call's parameter slots are reused every time it is called,
  so calling a function twice would only emit traces for the parameters
  that aren't the same Val.ID as the previous call.
- A VarDeclaration inside a loop reuses its slot each time through the
  loop, even though conceptually it's a "new" variable.

We now track a slot's "written-to" status. At the start of execution,
no slots have been "written-to". These slots will always emit a
trace_var opcode (fixing the first issue). Also, issuing a function
call or declaring a variable will reset the "written-to" status of the
associated slots (fixing the second and third issues).

When the debugger is not in use, the written-to field is unused.

Change-Id: I482a86cb6e90d0f85dd2a161e984f212782a7b4d
Bug: skia:12614
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/473776
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
6 files changed