<div dir="ltr">All the optimization passes I can find in the documentation, deal with register, stack or global values; I cannot find any mention of anything trying to optimize values on the heap. But this:<div><br></div><div>#include <stdlib.h><br><br>int main(int argc, char **argv) {<br>  int *a = malloc(10 * sizeof(int));<br>  for (int i = 0; i < 10; i++)<br>    a[i] = i;<br>  return a[5];<br>}<br></div><div><br></div><div>compiles to 'ret 5' (as it should). Which pass does that?</div></div>