<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54160>54160</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[stack-coloring] Increase in stack size after BB-layout change
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wolfy1961
</td>
</tr>
</table>
<pre>
After [1e3c6fc7cb9d](https://github.com/llvm/llvm-project/commit/1e3c6fc7cb9d2ee6a5328881f95d6643afeadbff) we're seeing an increase in stack size in function foo() in the attached example.
Platform: linux native.
Compile with: clang -O2.
The stack size increases from 192 to 304, and when looking at an IR dump, we see in the version before the above mentioned commit:
```
# *** IR Dump Before Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
fi#0: size=16, align=8, at location [SP+8]
fi#1: size=176, align=8, at location [SP+8]
fi#2: size=112, align=1, at location [SP+8]
...
# *** IR Dump After Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
fi#0: size=16, align=8, at location [SP+8]
fi#1: size=176, align=8, at location [SP+8]
fi#2: dead
```
whereas in the version after the change we see
```
# *** IR Dump Before Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
fi#0: size=16, align=8, at location [SP+8]
fi#1: size=176, align=8, at location [SP+8]
fi#2: size=112, align=1, at location [SP+8]
...
# *** IR Dump After Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
fi#0: size=16, align=8, at location [SP+8]
fi#1: size=176, align=8, at location [SP+8]
fi#2: size=112, align=1, at location [SP+8]
```
The change itself seems to be unrelated, as it affects jump threading, leading to a slightly different layout of BBs throughout the function.
[t.c.txt](https://github.com/llvm/llvm-project/files/8174575/t.c.txt)
(Apparently you can't attach a plain .c file, so I had to call it t.c.txt)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVk1v2zgQ_TXyZRBBor4POtgxCgTYokWTw14pcmQxpUSDpOKkv36Hkt04QbFFew4sWKREPr73ZkZkZ-RLu-09WoiKXYqZKHtRia6RUbGPWD14f3RRto3YJ7oOyg9zFwszUkfrp8vt5mjNIwpPXXo3qtC4xmKIJS8yVtd12jeFLMs84z1y2fV9xBo4YcQqi-AQ1XQAPoGahEXukBrgPBffwakfS6-fJ-GVoYYxRDBMp6d-QOCeBg4oAZ_5eNQYR8k-Srbr_1fNfW_sSFpAq2l-hol79XQZdGvGo9IIJ1IYhgjNicjNF_YG5IFWecNmJemgt2aEtGHgDWRJHrFbEiHhNOAE2pjviyofhN19AzmPxzDitAi-sH9C64KsDokmroI684Qw4hT0kq6zt9mZTVQm52vtsgwitl2vsM6e1oHdCvcZ7QFBKvdo1OQvIrTxjubUS_dGGG0sMQ2W_gR6XY3gP5O_akIiIpH8t2-DQbbdufv7bdD2YAnR_UMGT-jcivDJ8hHhSxcyxf3EBegVYSdhenA1yvZpuRio1WGiXr10PPko-LIWJer914jt6pCi1xjpNUb1lyDsGiRl1yDp70HiOP6_aKyV9hGMPwqGpA_FLzOeyivU3_sK4ovJ4YkYqIrxXGgfRfNRNB_B-C3IuwJ5eC0j5R3qPpTS6MJG1yHMk0XaWFEuuFSJtMf1fXAHHkPo_EAFKpeI3IJem2Eqp8ipw-D1C0WUJlja40DzFzN7MD3sdi5MNfNhCE9CKV_idMmUYudjEftn_5fnlJ52e0f3Oq3yoiqodcFjzSVd6u3xyAM1oknUQPCJzin-fNAgEUfN6dsTCwhoQaIzcAcDl0Gj4FoHQ15xN7LNZJM1fOOV19iSiHd5W-zh7tcnn_WjttvdnF1aY7KZrW7_WLtybl7EF3laJpuhLZOyLASyMpdZjVVZccHKsskxr5KmyvON5h1qFwhHjHVECidJK_5bU4oyYr1RLUsYSzL6saLJkph1KPKiqYTEMmOpjPIER650HLjExh42tl1odfPB0UutnHevL7lzlLG4eBTw-ewHY9uT0f1L2pTpZtHQLgL-A0Q-PmM">