<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/89045>89045</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [analyzer] Serious slowdown on FFmpeg sheervideo.c when using ArrayBoundV2
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:static analyzer
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          steakhal
      </td>
    </tr>
</table>

<pre>
    When release testing on top of clang-18, I noticed some significant (many X) slowdown on certain projects, e.g. on FFmpeg.
When investigated, the most impacted TU was `sheervideo.c`, where we had 33 seconds in the past, but now it takes around 1.23 **hours** to analyze. At that point, I'd count it as a hang.

After bisecting, the blamed change was #72107 `Switch to PostStmt callbacks in ArrayBoundV2`.

I used `perf` to get a glimps on where we spend our time, and here is how it looks:
![image](https://github.com/llvm/llvm-project/assets/6280485/293b7227-b0b0-47bc-9948-f42bea93d54d)

The `OOBv2` checker checks array subscripts, and then it spends most of its time on traversing symbols to see if any of it is tainted.

I've also checked that prior to this change, the maximum `Sym->computeComplexity()` within `getTaintedSymbolsImpl` was significantly lower than after the change. After the change this maximal complexity was more around the threshold (35), 30-33.

I dumped the state when the `getTaintedSymbolsImpl` appeared 63 times in the call stack and the state dump itself, was huge.
Several if not all lines individually taking up 26 Megabytes.
Many of these lines encoded the history of some "hashing-like" computation.

I'm not there yet to make suggestions for a fix, but I anyways wanted to let you know. @NagyDonat

Here is the preprocessed reproducer:
[sheervideo.zip](https://github.com/llvm/llvm-project/files/15009479/sheervideo.zip)

Here is the command to run it:
```
./build/bin/clang -cc1 -analyze -analyzer-checker=core,alpha.security -analyze-function=decode_c82p -analyzer-display-progress preprocessed_sheervideo.c
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVk1v4zYQ_TX0ZWBDpmTLOvjgbGo0h-0WyPbjtqDIkcSaIgWSsl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