Skip to content
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

Fix llvm-assertion: don't instantiate 0-sized structs (ghost types) #31431

Merged
merged 5 commits into from
Mar 25, 2019

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Mar 21, 2019

I created this commit from a patch that @JeffBezanson sent me. I'm not familiar with this code myself, so I don't know if this is sufficient, but I wanted to open this PR so that we didn't forget about this fix! :) Feel free to commit to it directly / take it over / replace it with a new PR or whatever.

In particular, we were a bit unsure about what should go in the second else block, where we currently put return e;.


As I understand it, LLVM doesn't support 0-sized structs (ghost types),
which julia makes significant use of. This fixes an incorrect behavior
in the julia compiler accidentally attempting to instantiate such
0-sized structs.

When using a debug build of LLVM, this fails with an assertion error,
but failed silently on standard LLVM.


This came up when debugging #31418.

As I understand it, LLVM doesn't support 0-sized structs (ghost types),
which julia makes significant use of. This fixes an incorrect behavior
in the julia compiler accidentally attempting to instantiate such
0-sized structs.

When using a debug build of LLVM, this fails with an assertion error,
but failed silently on standard LLVM.
@NHDaly
Copy link
Member Author

NHDaly commented Mar 21, 2019

Also i think this should get some tests as well.

src/intrinsics.cpp Outdated Show resolved Hide resolved
src/intrinsics.cpp Outdated Show resolved Hide resolved
@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 21, 2019

fixes #29929

@JeffBezanson JeffBezanson added compiler:codegen Generation of LLVM IR and native code bugfix This change fixes an existing bug labels Mar 21, 2019
vtjnash and others added 2 commits March 21, 2019 21:42
Co-Authored-By: NHDaly <NHDaly@gmail.com>
replace `mark_julia_type()` with `return e` always.
@NHDaly
Copy link
Member Author

NHDaly commented Mar 22, 2019

I applied your suggestions. I don't know what this code does so i'm acting blind. :)

@NHDaly
Copy link
Member Author

NHDaly commented Mar 22, 2019

I've added a test case for #29929 and a few others that exercise this change.

@StefanKarpinski
Copy link
Sponsor Member

Any reason not to merge? This PR appears to have a higher percentage of green checkmarks that I no longer know the meaning of than the average PR.

@vchuravy vchuravy merged commit 92a361b into JuliaLang:master Mar 25, 2019
@JeffBezanson
Copy link
Sponsor Member

JeffBezanson commented Mar 25, 2019

Should have squashed!! 😠

@NHDaly NHDaly deleted the nhdaly-llvm-ghost-types branch March 25, 2019 21:39
@vchuravy
Copy link
Member

Mea culpa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants