<div dir="ltr">Chris added alloca merging in the inliner a looooong time ago, 2009. The reason he added it was because at the time we didn't do stack coloring and without it we had serious stack size problems in LLVM.<div><br></div><div>Since then, a few rather important things have changed:</div><div>- We have reasonably powerful stack coloring support in the backend based on lifetime markers</div><div>- Clang<span class="inbox-inbox-Apple-converted-space" style="line-height:1.5"> </span><span style="line-height:1.5">(the primary frontend I'm aware of that hit issues with this)</span><span style="line-height:1.5"> is now emitting lifetime markers for essentially everything</span></div><div>- Clang even has front-end based -O0 stack reuse tricks</div><div>- AliasAnalysis has become even more important (extended to codegen time etc) and relies heavily on distinguishing between allocas.</div><div>- We have lots of tools like the sanitizers that directly reason about allocas to catch bugs in user programs.</div><div><br></div><div>The first two changes pretty much completely obviate the need for alloca merging as far as I'm aware, and the second two changes make the information loss caused by this practice, IMO, really bad.</div><div><br></div><div>Even if there are problems exposed by turning off alloca merging in the inliner, they are almost certainly deficiencies in stack coloring, Clang, or other parts of the optimizer that we should fix rather than continue to ignore.</div><div><br></div><div>Thoughts? The code changes are easy and mechanical. My plan would be:</div><div>1) Add a flag to turn this off.</div><div>2) Run benchmarks with flag to make sure things are actually working.</div><div>3) Change default for the flag, make sure chaos doesn't ensue.</div><div>4) Delete the (quite substantial) complexity associated with this and the flag.</div><div>5) Profit!</div><div><br></div><div>-Chandler</div></div>