ponyc
                                
                                 ponyc copied to clipboard
                                
                                    ponyc copied to clipboard
                            
                            
                            
                        Improve the heap to stack optimisation pass
This optimisation pass, which turns heap allocations into stack allocations, currently doesn't handle stores at all and gives up as soon as it sees one.
Line 314 of genopt.cc says "if we store the pointer in something that is stack allocated is it still captured?" The answer to this question is to find all the loads clobbered by the store and to treat them as derived pointers (i.e. the original pointer isn't captured if every derived pointer is neither captured nor reused). This is trivial to do (with some knowledge of LLVM) in LLVM 3.9 with the MemorySSA analysis pass. It can also be done in LLVM 3.8 and below with the MemDep analysis pass but it is less straightforward.