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

    <tr>
        <th>Summary</th>
        <td>
            __hwasan_test_shadow performance issues
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    I was experimenting on doing checks beforehand for HWAsan in some high performance code and I realized that checking beforehand was much slower than software ASan.

That seems to be because while `__asan_region_is_poisoned` has a fast path that checks the start and end before doing a slow O(n) scan, the near equivalent `__hwasan_test_shadow` is always a slow O(n) byte by byte loop.

It is also a simple byte loop so, assuming page boundaries are accounted for, both could probably be converted to a fast SIMD loop like strlen or memchr. This could make it a lot more viable for checking bounds in advance.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxskzFv4zgQhX8N1QxiSJRiW4UK3wXGuThckQBXGkNyLPJCkToOZa_31y9oO0gWuxVVvPf46c0Qmd0YiAbx_Id4fqlwyTamgZCvyLNrm65S0VyHA1yQgb7NlNxEIbswQgxgYvnQlvQ7g6JTTGQxGDjFBH_9u2MM4AJwnAisGy3MlE4xTRg0gY6GoIgPkAi9-04GssV8jyu5XwLL7dOiLbCPF0pFWHJP-YKJYPeKYSXqnah3byWBiSaGHEERKNK4MMHFOk8g1vXxiIzhmGh0MRwdH-foOAYyYl2DRQaEE3KGGbP9AsSQLQFnTPlGTcE8AB8t4I0N_hFyG4TsgTUGIf-82QJhAvp_cWf0FPIdw15uIJk4H9miiZdC4BjQX_DKvwSqayZQ1_vpY5wfv3zIdxPHYnHT7OlTAxwLBDIvU6GccSRQcQkGkyOGUh9qHZeQ6Ta3olYxW9Bx8QbmFBUqfy1V6hjOlIoux4-WXg9_v9wv8u699JM8BYgJJpq0TSt4s44fWRO-E7gMCD5mmEp1Z4fK021fPsde6LgsDppzWZVVZYbW9G2PFQ3NptnIzbpt15Ud2s2m60nVvW5It31vTqS7ntb9tj21Zrup3CBr2dXrupFNI5v1qlM9SvnckpEb2tZKdDVN6PzK-_O0immsHPNCQ981sqs8KvL88TjSUERPahlZdLV3nPnTll32NPxuqj9t_S2dqyX5weY8s2h3Qu6F3I8u20WtdJyE3JfUx_E0p_gf6Szk_u4Vcn-HOw_yRwAAAP__2HtKwQ">