Skip to content

LLVM crash lowering arithmetic on address of global on x86 with glibc #18034

@mlugg

Description

@mlugg

Zig Version

0.12.0-dev.1643+91329ce94

Steps to Reproduce and Observed Behavior

var x: u8 = 0;
export fn f() void {
    const addr = @intFromPtr(&x);
    g(addr & 0xff == 0);
}
fn g(_: bool) void {}
$ zig build-obj repro.zig -target x86-linux-gnu -lc
LLVM Emit Object... zig: /home/mlugg/llvm-project-17/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:284: llvm::Register llvm::InstrEmitter::getVR(llvm::SDValue, llvm::DenseMap<llvm::SDValue, llvm::Register>&): Assertion `I != VRBaseMap.end() && "Node emitted out of order - late"' failed.
Aborted

Expected Behavior

It should not crash :)

This reproduction requires linking glibc despite not using any libc symbols.

The issue does not reproduce when attempting to compile the output of --verbose-llvm-ir with llc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x8632-bit x86backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions