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

Broken LLVM Module from loop expression with continuation, conditional continue, break value, and else unreachable #7370

Open
SpexGuy opened this issue Dec 9, 2020 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@SpexGuy
Copy link
Contributor

SpexGuy commented Dec 9, 2020

// test.zig
export fn foo() void {
    var x: bool = false;
    const v = // : usize here fixes the problem
        while (x) : ({}) { // for loop has the same problem
            if (x) continue;
            break @as(usize, 0);
        } else unreachable;
}
> zig version
0.7.0+97c0e1cc4

> zig build-obj test.zig
Code Generation [247/468] std.mem.Allocator.reallocAdvancedWithRetAddr... broken LLVM module found: 
Terminator found in the middle of a basic block!
label %WhileElse

This is a bug in the Zig compiler.
src\stage1.zig:168:5: 0x7ff6705c21cf in stage2_panic (zig.o)
    @panic(ptr[0..len]);
    ^
src\stage1\util.cpp:20:0: 0x7ff6705772b0 in zig_panic (util.o)
    stage2_panic("", 0);

src\stage1\codegen.cpp:8412:0: 0x7ff67044ca28 in do_code_gen (codegen.o)
    if (LLVMVerifyModule(g->module, LLVMReturnStatusAction, &error)) {

src\stage1\codegen.cpp:9555:0: 0x7ff67044951f in codegen_build_object (codegen.o)
    {

src\stage1\stage1.cpp:127:0: 0x7ff67057117c in zig_stage1_build_object 
(stage1.o)
    codegen_build_object(g);

src\stage1.zig:140:32: 0x7ff6708d6556 in Module::Module.build_object (zig.o)
        zig_stage1_build_object(mod);
                               ^
src\Compilation.zig:3003:31: 0x7ff6707229af in Compilation.updateStage1Module (zig.o)
        // We need to save the inferred link libs to the cache, otherwise if we get a cache hit     
                              ^
src\Compilation.zig:1533:36: 0x7ff6706ddb53 in Compilation.performAllTheWork (zig.o)
            self.updateStage1Module(main_progress_node) catch |err| {
                                   ^
src\Compilation.zig:1227:31: 0x7ff6706d7a58 in Compilation.update (zig.o)
    try self.performAllTheWork();
                              ^
src\main.zig:1918:20: 0x7ff670685f57 in main.updateModule (zig.o)
        }
                   ^
src\main.zig:1780:17: 0x7ff6705d764d in main.buildOutputType (zig.o)   
    }
                ^
src\main.zig:164:31: 0x7ff6705c1291 in main.mainArgs (zig.o)
        return buildOutputType(gpa, arena, args, .{ .build = .Obj });
                              ^
src\stage1.zig:45:24: 0x7ff6705c0e05 in main (zig.o)
        stage2.mainArgs(gpa, arena, args) catch unreachable;
                       ^
@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 Dec 11, 2020
@Vexu Vexu added this to the 0.9.0 milestone Dec 11, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@nektro
Copy link
Contributor

nektro commented Jun 15, 2022

can confirm still present in 0.10.0-dev.2617+47c4d4450, just ran into this

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

4 participants