ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.69k stars 410 forks source link

LLVM Optimization Pass Crash on Merge successive reallocations of the same variable #3420

Open ergl opened 4 years ago

ergl commented 4 years ago

I managed to reproduce the same behaviour as https://github.com/ponylang/ponyc/issues/3126 with the following code:

actor Main
  let a: Array[(U64, U64)] = [as (U64, U64):
    (0,0); (1,0); (2,0); (3,0); (4,0); (5,0); (6,0)
    (7,0); (8,0); (9,0); (0,2); (9,2); (0,3); (9,3)
    (0,4); (9,4); (0,5); (9,5); (0,6); (9,6); (0,7)
    (9,7); (0,8); (9,8); (0,9); (1,9); (2,9); (3,9)
    (4,9); (5,9); (6,9); (7,9); (8,9)
  ]

  new create(env: Env) => None

(although the code works correctly in the pony playground)

Compiling the above:

$ ponyc test/
Building builtin -> /usr/local/Cellar/ponyc/0.33.0/packages/builtin
Building test/ -> ~/Downloads/test
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Stack dump:
0.  Running pass 'Function Pass Manager' on module 'test'.
1.  Running pass 'Merge successive reallocations of the same variable' on function '@Main_Dispatch'
Segmentation fault: 11

This is on macOS Mojave 10.14.6, ponyc version:

ponyc --version
0.33.0 [release]
compiled with: llvm 7.1.0 -- Apple clang version 11.0.0 (clang-1100.0.33.8)
Defaults: pic=false
SeanTAllen commented 4 years ago

Is this the same issue or a different issue @ergl. It sounds like the same issue from your description. If it is, please add a note to #3126 and close this one.

ergl commented 4 years ago

Sorry, yes, it's the same issue, I'll add a comment there, thanks!

SeanTAllen commented 4 years ago

This fails with the latest LLVM.

SeanTAllen commented 2 years ago

Still an issue. Only happens with optimized builds so it has to be something in an optimization pass.