Skip to content

Compiler bug: broken LLVM module found: Instruction does not dominate all uses! #7966

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

Closed
croscato-zz opened this issue Feb 6, 2021 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@croscato-zz
Copy link

This two lines of code, when compiled with zig version 0.8.0-dev.1120+300ebbd56 results in the compile error bellow.

print("w: {d}\n", .{ if (char_count > kTgaCharPerLine) width * kTgaCharPerLine else width * char_count });
print("h: {d}\n", .{ if (char_count > kTgaCharPerLine) height * kTgaCharPerLine else height });

I've tried create a minimal version that cause the problem without success. When a extracted this two lines of code, with it's dependencies, variables e constants, to another project the error doesn't happen.

In this attached zip is the project, in the state that, when build gives the mentioned error.

bft2img.zip

Compile error

broken LLVM module found: Instruction does not dominate all uses!
  %554 = getelementptr inbounds %"struct:151:32", %"struct:151:32"* %66, i32 0, i32 0, !dbg !16451
  store i32 %438, i32* %554, align 4, !dbg !16452
Instruction does not dominate all uses!
  %553 = getelementptr inbounds %"struct:150:32", %"struct:150:32"* %65, i32 0, i32 0, !dbg !16442
  store i32 %430, i32* %553, align 4, !dbg !16445

This is a bug in the Zig compiler.thread 14719 panic:
Unable to dump stack trace: debug info stripped
bft2img...The following command terminated unexpectedly:
/usr/bin/zig build-exe /misc/projetos/util/bft2img/src/main.zig --cache-dir /misc/projetos/util/bft2img/zig-cache --global-cache-dir /home/croscato/.cache/zig --name bft2img --pkg-begin color /misc/projetos/util/bft2img/lib/color.zig --pkg-end --pkg-begin tga /misc/projetos/util/bft2img/lib/tga.zig --pkg-end -isystem /misc/projetos/util/bft2img/lib --enable-cache
error: the following build command failed with exit code 6:
/misc/projetos/util/bft2img/zig-cache/o/59ccf733c530ca41655279809d9aed7b/build /usr/bin/zig /misc/projetos/util/bft2img /misc/projetos/util/bft2img/zig-cache /home/croscato/.cache/zig
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Feb 6, 2021
@Vexu Vexu added this to the 0.9.0 milestone Feb 6, 2021
@Vexu
Copy link
Member

Vexu commented Feb 6, 2021

I'm pretty sure this is a duplicate but I can't find the issue right now. Workaround should be as easy as assigning the if to a variable:

const foo = if (char_count > kTgaCharPerLine) width * kTgaCharPerLine else width * char_count };
print("w: {d}\n", .{foo});

@data-man
Copy link
Contributor

data-man commented Feb 7, 2021

I'm pretty sure this is a duplicate but I can't find the issue right now.

https://github.com/ziglang/zig/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+Instruction+does+not+dominate+all+uses

@g-w1
Copy link
Contributor

g-w1 commented Feb 7, 2021

#3882 #6302

@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@Vexu Vexu closed this as completed Dec 28, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

5 participants