sanitizer-coverage: comparison instrumentation should do minimal backtracking of operands
- Dominant language
- C
- Stars
- 12.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Some real cases:
```c
void foo(uint32_t x)
{
// optimized version of (x > 10 && x < 30)
if (x - 10 < 20) ...
}
int32_t bar(int32_t x, int32_t y, int32_t w, int32_t z)
{
// memcmp-like comparison
int32_t d = x - y;
if (d)
return d;
d = w - z;
if (d)
return d;
...
}
void baz(int32_t x)
{
if (((x & 0xff00) >> 8) == 0xab) ...
}
```
In all of these cases comparison instrumentation produces unuseful results.
Instrumentation should, if possible, transform comparisons to the form where one of the operands is a variable as-is:
```
# if (x - 10 < 20) ...
if (x > 10 && x < 30)
# int32_t d = x - y;
# if (d)
if (x != y)
# if (((x & 0xff00) >> 8) == 0xab) ...
if (x == ((0xab << 8) | (x & ~0xff00)))
```
Contributor guide
Research direction
Start with the three C examples in the issue and trace where sanitizer-coverage comparison instrumentation handles their operands. Define completion as producing equivalent comparisons with minimal operand backtracking, including range, subtraction-chain, and masked-shift cases; no source files or tests are named, so the relevant instrumentation entry point and regression-test location must first be identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100