Closed elliottslaughter closed 1 year ago
Adding getGammaTableArrayBig:setinlined(false)
produces a slightly different error (presumably just moving the same error to a different site):
$ ./regent.py test3_min_terra.t
extern global gamma_table : double[700][18]
0 terra (JIT) 0x000000010fc74271 $getGammaTableArrayBig + 33
1 terra 0x000000010aa72a45 lj_ccall_func + 2101
2 ??? 0x000000000000001b 0x0 + 27
Edit: I also ran LLVM 7, and the results look very similar to LLVM 13.
Edit 2: all of this on macOS x86_64.
Confirmed that LLVM 7 is going through this code path:
The root cause appears to be that starting in LLVM 7, Clang changed the way that it encodes certain global variables. In particular, arrays with trailing zeros appear to be reencoded as a struct containing two sub-arrays, one with the non-zeros and one with zeroes.
This is pretty clear if you dump the full LLVM IR for the complete examples:
@gamma_table = local_unnamed_addr constant [18 x [700 x double]] ...
@gamma_table = local_unnamed_addr constant <{ <{ [680 x double], [20 x double] }>, <{ [658 x double], [42 x double] }>, <{ [639 x double], [61 x double] }>, <{ [624 x double], [76 x double] }>, <{ [610 x double], [90 x double] }>, <{ [598 x double], [102 x double] }>, <{ [587 x double], [113 x double] }>, <{ [577 x double], [123 x double] }>, <{ [569 x double], [131 x double] }>, <{ [560 x double], [140 x double] }>, <{ [553 x double], [147 x double] }>, <{ [546 x double], [154 x double] }>, <{ [540 x double], [160 x double] }>, <{ [534 x double], [166 x double] }>, <{ [528 x double], [172 x double] }>, <{ [523 x double], [177 x double] }>, <{ [518 x double], [182 x double] }>, [700 x double] }> <{ <{ [680 x double], [20 x double] }> <{ [680 x double] ...
So then there's a question of what to do about it. Some options:
Nevermind, I was just doing the cast wrong. Fix in https://github.com/terralang/terra/pull/631.
This reproducer was minimized from a Regent program discussed in https://github.com/StanfordLegion/legion/issues/1385.
https://gist.github.com/elliottslaughter/c8bc2252c92639f8d3618b9bf3d33fb2
Running with Terra compiled with any LLVM version > 6 produces (in this case, with LLVM 13):
Running with Terra compiled with LLVM 6 produces:
The issue seems to have something to do with the array we're bringing in via the header file.
I tested macOS x86_64. I believe the issue also occurs on Linux x86_64.