Skip to content

LLVM lowerDebugType: Lower union types without a layout into an empty namespace - #19182

Merged
Vexu merged 2 commits into
ziglang:masterfrom
antlilja:llvm-unresolved-union
Mar 17, 2024
Merged

LLVM lowerDebugType: Lower union types without a layout into an empty namespace #19182
Vexu merged 2 commits into
ziglang:masterfrom
antlilja:llvm-unresolved-union

Conversation

@antlilja

@antlilja antlilja commented Mar 4, 2024

Copy link
Copy Markdown
Contributor

Fixes #18518

I think the bug is actually in the llvm backend and not the frontend as the union type actually isn't used at runtime, only the field type is referenced and thus the union does not get a layout. The fix implemented here just emits an empty namespace as a debug type for unions without layout. I don't think this fix should have any real consequences on the debugability of programs as there won't ever be values with that debug type.

@schmee

schmee commented Mar 4, 2024

Copy link
Copy Markdown
Contributor

Nice! A test would be neat, maybe the one from #19145 could be added here (if it's valid)?

@antlilja
antlilja force-pushed the llvm-unresolved-union branch from dc6abbf to 1179575 Compare March 5, 2024 12:58
@antlilja

antlilja commented Mar 5, 2024

Copy link
Copy Markdown
Contributor Author

Good point, I've added a test case

@antlilja
antlilja force-pushed the llvm-unresolved-union branch from 1179575 to a70aa53 Compare March 14, 2024 12:31

@Vexu Vexu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the test from the previous pr not cause a crash without this fix or why did you change it into a check output test?

@antlilja

Copy link
Copy Markdown
Contributor Author

Did the test from the previous pr not cause a crash without this fix or why did you change it into a check output test?

I think it did cause a crash. I moved it as it didn't seem like a union behavior test. But maybe I'm misinterpreting how the tests are organized and the use of the term "behavior".

@Vexu
Vexu merged commit 294f518 into ziglang:master Mar 17, 2024
@antlilja
antlilja deleted the llvm-unresolved-union branch March 17, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segmentation fault on accessing fields of tagged unions

3 participants