<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63304>63304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`clangtk` hangs when processing expression with deep dependency and type intptr_t
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wierton
</td>
</tr>
</table>
<pre>
When the following code is compiled using `clangtk` with the `-O1` option, the compiler hangs indefinitely. This behavior can be reproduced at https://gcc.godbolt.org/z/KeEnoKbTP:
```c
#include <stdint.h>
typedef intptr_t T; // T is aliased to intptr_t
char *bar (void);
T baz (void);
long foo_q;
void foo (T *q) {
char *p = bar ();
T a = baz ();
T b = baz ();
int i = 0;
#define X q[i++] = a; q[i++] = b; a = a + b; b = b + a;
#define Y X X X X X X X X X X
#define Z Y Y Y Y Y Y Y Y Y Y
Z;
p[a] = 1;
p[b] *= 2;
}
```
However, when the type `T` is aliased to `int` instead of `intptr_t`, the compilation is completed quickly without any issues. The modified code can be found at https://gcc.godbolt.org/z/K818h6dzx:
```c
#include <stdint.h>
typedef int T; // T is aliased to int
char *bar (void);
T baz (void);
long foo_q;
void foo (T *q) {
char *p = bar ();
T a = baz ();
T b = baz ();
int i = 0;
#define X q[i++] = a; q[i++] = b; a = a + b; b = b + a;
#define Y X X X X X X X X X X
#define Z Y Y Y Y Y Y Y Y Y Y
Z;
p[a] = 1;
p[b] *= 2;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzslc-SozYQxp-muXSNS0jA2AcO4_W6UrWH5OCq7O5lS0htUFaWGCTG63n6lADv_E0lh9ySggL7-yR1C_pHyxBM64hqKLdQ7jI5xs4P9dnQEL3LGq8v9e8dOYwd4dFb68_Gtai8JjQBlT_1xpLGMSQZKqasdG38DhXDs4ndNA8qdvNrniTfR-Md8A-TvswesJOuDWicpqNxJpK9rPDQmYANdfLB-AGVdNgQDtQPXo-KNMqIXYx9AHEHfA983yq1ar1uvI0rP7TA94_A95_oo_OfmsNvaRzbAbteKzafavnPhXHKjpoQxIcQtXFx1YH4ONvx0pOmIxoX-zh8i3gAscU5MB7So5DWyEAao_85aJ6qOjkg8Ltmuq0fvNHANyC2s33ARj6-Z8xX612LR--_3f800sAkpUmHtPI98A3C7WIjXiP2CGKHS9znSyMeUC7m43tm89emcRHNZLOnVLmYXh3hZ7yHcmuAb9NZ7qaBMj2rd_Qm6XMeEoFvZ2GJPQnynRBf8PPb4_Wgr_jl7XHdwtdn2-mh3MprQvkro5kMfpc8_pTK7e5VDT1_Yb_4Mz3QkGr8fAUnVU-i4JAYeFkrUDHj4qS7EElq9MdFnGuoYi9xkYmgK3uWImm8H436bi8TcH6MKN0FTQgjhYQR4clrczSkZ2wXlI5-dP-conW-7ir9-ONfo-jvAPqfnf8UO5muhd6Ijcyozqt1dVuwciOyrl6zRlclK3LOy5IzVhZVvi7LvFDHSumyyUzNGResyos8ZyIXKypuhV4zzitFG9owKBidpLErax9OqaaziY26EoIVmZUN2TC1P84dnWdwgPPUDYc6zblpxjZAwawJMTytEk20VL9seXMjm7jvB68oTG2RfvRD-und3BM1UY-aenKanLqgdHr-RFyhz8bB1q-4NLEbm5XyJ-D7lMNyu-kH_wepCHw_Iw98P-3szwAAAP__Cww02g">