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

    <tr>
        <th>Summary</th>
        <td>
            Lousy spilling in the RegAlloc's
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Hi,

I'm populating llvm through `IRBuilder` with some 400+ `Alloca's`, most of them 8 byte double types.

The total stack size pumped via. the `Alloca's` is 3520 bytes.

The stack size after `RegAllocBasic`, or `RegAllocGreedy`, or `RegAllocPBQP` varies between 7320 - 7480 bytes.

That's more than double the stack size needed, the extra of which appear to be originating from spills.

The bottom line is there's likely as much code managing irrelevant spills as there is real code, and further, the spills introduce a 2nd unnecessary 4k page.

This ugliness only became apparent when I introduced in the pipeline prior to populating llvm a modified Lal George and Andrew Appel, "Iterated Register Coalescing" algorithm. The output of this algorithm coalesces stack symbols such that the 3520 bytes from the `Alloca's` is about as close to minimal as can be obtained. Thus, llvm's `RegAlloc's` compress the stack no further. Prior to doing this the size pumped through `Alloca's` was 156728 bytes, and the llvm stack size of 7480 bytes seemed impressive. Right. Not happy.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0lN9u6zYMxp9GuSFqOLITJxe-SDr0rMDB0BV7Adqiba36Y0h0suzpBynNSXq2XRkwxU8_kh-FMerREbVicxSbX1a48ORDe_Tdtq6azarz6tL-qoV8FuVBlIdXIRsLs58Xg6zdCMacLPAU_DJOILbl6_tx0UZRENsSzponiN4S1GUp5DEdOBjjexSyiWJbCvkM1kcGPwBPZGEH3YUJlF86Q8CXmWJxvfmPiYA9o4HI2H9A1H8TzIudScFJY5Hy_6UPOkK1kWVWfVR60MCBKaTMdxpz8hGj7j_h_JfIt0CkLv8Zejv-_pYuPGHQFKEjPhM5aCpZ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