<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62191>62191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[GlobalOpt] Excessive compile time after memset related change
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wolfy1961
</td>
</tr>
</table>
<pre>
After [f65c88c42](https://github.com/llvm/llvm-project/commit/f65c88c42fdd0e46d16fe31737e6627c56de77c3) we're seeing a lot of time spent in GlobalOpt with the following C++ code, when compiled with clang -c -O3:
```
#if defined(LONGER)
#define ELTYPE B
#else
#define ELTYPE A
#endif
unsigned int getIndex();
struct A
{
A() : m_p(nullptr) { }
void* m_p;
};
struct B
{
A m_a;
};
ELTYPE Entries[2097151] = {};
static ELTYPE GetElement( )
{
return Entries[getIndex()];
}
```
With -ftime-report I'm seeing about 3 seconds spent in GlobalOpt on a linux box, and with -DLONGER the time in GlobalOpt seems to triple. A real-world example from one of our licensees sees compile time going from 4 seconds to over 200, all due to GlobalOpt.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVFuL4zYU_jXyyyFBl_j24IdkkwwLS6eUQunTIkvHjoosGUmeZP99sZPxzLTTwoKRLZ3bd44-fzJG0zvEhuQHkh8zOaWLD83V2-4HqwuWtV7_aPZdwgAkP3RFrqpK7TjJj4RXl5TGSMSe8DPh596ky9RulR8IP1v78vrajMH_hSoRflZ-GMz8sSbqtKa4KzQrOhSsFCUWBS9VXmgsSyUIr-GKhJcBISIa14ME6xP4DpIZEOKILoFx8GR9K-3zmOBq0gXSBaHz1vrrHPOF8APhB1BeI-Ff4HpBB8oPo7Go7wHKStfDRsHmWcwt0SOhe1LQx3PfcmE60NgZh5rw6tvzL0-n3wivV_PdBqdvv__56wkO6znaiP_htH9zctp0j92yTm65HQ3GJegxfXUab4RXc0VxeO8ZU5hUWnOVDyPA_u4OROxh-D4SXrnJ2jGF5bA8ACmPr74v3mjC735r-vL4eanDv0vB8F3-T-Cj35NLwWAk-YHTumQ5I_kRiDjOaD6rJpNRr7N6wnSyOKBLhFfwNvg3EAHTFNy7Iv8YW378gPDTW17WP2ZSbLqZZJuAow8JvhJeDisNWz8lEBBReafjZ0T0biarcdMNWn-beSfdg22b4507C08XIn-IjIhDhOQhBTNa3MIeAkq7ufpgNeBNDqNF6IIfwDucfwY_BbBGoYuIEZblwe97-t7PoJeI3Yo5efAvGIBTuqCzFvSE8_EKZZvpRuha1DLDhhUVK8uKMpZdmrxSsmXlTpQ1djsqUZWFQFozpJQx2mam4ZQLumMVpUIItmWSyUoyntO8q1uBZEdxkMZuZ5XY-tBnJsYJm4KzmmVWtmjjIkycO7zCYiR81p4sNIuytFMfyY5aE1N8y5JMsouirV3MFDvdFMZoXvDjYOSibQMOERMEtDKhBnWRrsdsCrb5aY1bYEbCz0sbfwcAAP__NdCeMQ">