-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miscompilation with LLVM > 6 #630
Comments
Adding
LLVM 13 disas (optimized)
LLVM 13 disas (unoptimized)
LLVM 6 disas (optimized)
LLVM 6 disas (unoptimized)
For posterity, the version of the reproducer used in this testlocal c = terralib.includec("stdlib.h")
local gamma_header_big = terralib.includec("gamma_table_min.h", {"-I", "./"})
print(gamma_header_big.gamma_table)
terra getGammaTableArrayBig(j : int, index : int) : double
var gval: double
gval = gamma_header_big.gamma_table[j][index]
return gval
end
getGammaTableArrayBig:setinlined(false)
getGammaTableArrayBig:setoptimized(false)
getGammaTableArrayBig:disas()
terra g3d(r_gamma_table : &double, N : int, M : int)
for x = 0, N do
for y = 0, M do
r_gamma_table[x * M + y] = getGammaTableArrayBig(x, y)
end
end
end
terra main()
var N = 18
var M = 700
var r_gamma_table_big = [&double](c.malloc(N*M*terralib.sizeof(double)))
g3d(r_gamma_table_big, N, M)
end
main() Edit: I also ran LLVM 7, and the results look very similar to LLVM 13. Edit 2: all of this on macOS x86_64. |
A couple places in the code possibly worth checking: Lines 1295 to 1299 in 7ad7756
Lines 2526 to 2530 in 7ad7756
|
Confirmed that LLVM 7 is going through this code path: Lines 2528 to 2530 in 7ad7756
|
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:
So then there's a question of what to do about it. Some options:
|
Nevermind, I was just doing the cast wrong. Fix in #631. |
This reproducer was minimized from a Regent program discussed in StanfordLegion/legion#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.
The text was updated successfully, but these errors were encountered: