lks9 / src-tracer

Other
0 stars 0 forks source link

Switch: Don't instrument doubled cases twice #59

Closed lks9 closed 4 months ago

lks9 commented 4 months ago

Example:

switch (i) {
  case 0: case 1:
    a = 1;
  default:
}

Instrumented:

_SWITCH_START(sw0, 2) switch (i) {
  case 0: _CASE(0, sw0, 2) case 1: _CASE(1, sw0, 2)
    a = 1;
  default: _CASE(2, sw0, 2)
}

We can use only 1 bit instead of 2 if we don't instrument case 0. Then the trace for case 0 and case 1 (prior NN, NT) would be the same N:

_SWITCH_START(sw0, 1) switch (i) {
  case 0: case 1: _CASE(0, sw0, 1)
    a = 1;
  default: _CASE(1, sw0, 1)
}
lks9 commented 4 months ago

closed wrong issue by mistake...