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

when compiling for znver3, LLVM assertion: Value does not fit in the Fixup field #17902

Closed
andrewrk opened this issue Nov 6, 2023 · 3 comments
Labels
arch-x86_64 64-bit x86 backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior os-windows upstream An issue with a third party project that Zig uses.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Nov 6, 2023

zig test ReleaseFast native: error: Assertion failed: (Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field", file /home/andy/dev/zig-bootstrap/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp, line 715

zig test ReleaseFast native: error: the following command exited with error code 3:
D:\a\zig\zig\build-release\stage3-release\bin\zig.exe test D:\a\zig\zig\lib\std\std.zig -OReleaseFast --cache-dir D:\a\zig\zig\zig-cache --global-cache-dir C:\Users\runneradmin\AppData\Local\zig --name test -I D:\a\zig\zig\test -L D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\lib -I D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\include --zig-lib-dir D:\a\zig\zig\lib --listen=- 
zig test ReleaseSafe native: error: Assertion failed: (Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field", file /home/andy/dev/zig-bootstrap/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp, line 715

zig test ReleaseSafe native: error: the following command exited with error code 3:
D:\a\zig\zig\build-release\stage3-release\bin\zig.exe test D:\a\zig\zig\lib\std\std.zig -OReleaseSafe --cache-dir D:\a\zig\zig\zig-cache --global-cache-dir C:\Users\runneradmin\AppData\Local\zig --name test -fsingle-threaded -I D:\a\zig\zig\test -L D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\lib -I D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\include --zig-lib-dir D:\a\zig\zig\lib --listen=- 
zig test ReleaseFast native: error: Assertion failed: (Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field", file /home/andy/dev/zig-bootstrap/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp, line 715

zig test ReleaseFast native: error: the following command exited with error code 3:
D:\a\zig\zig\build-release\stage3-release\bin\zig.exe test D:\a\zig\zig\lib\std\std.zig -OReleaseFast --cache-dir D:\a\zig\zig\zig-cache --global-cache-dir C:\Users\runneradmin\AppData\Local\zig --name test -fsingle-threaded -I D:\a\zig\zig\test -L D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\lib -I D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\include --zig-lib-dir D:\a\zig\zig\lib --listen=- 
zig test ReleaseSafe native: error: Assertion failed: (Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field", file /home/andy/dev/zig-bootstrap/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp, line 715

zig test ReleaseSafe native: error: the following command exited with error code 3:
D:\a\zig\zig\build-release\stage3-release\bin\zig.exe test D:\a\zig\zig\lib\std\std.zig -OReleaseSafe --cache-dir D:\a\zig\zig\zig-cache --global-cache-dir C:\Users\runneradmin\AppData\Local\zig --name test -I D:\a\zig\zig\test -L D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\lib -I D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\include --zig-lib-dir D:\a\zig\zig\lib --listen=- 
zig test ReleaseFast native: error: Assertion failed: (Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field", file /home/andy/dev/zig-bootstrap/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp, line 715

zig test ReleaseFast native: error: the following command exited with error code 3:
D:\a\zig\zig\build-release\stage3-release\bin\zig.exe test D:\a\zig\zig\lib\std\std.zig -lc -OReleaseFast --cache-dir D:\a\zig\zig\zig-cache --global-cache-dir C:\Users\runneradmin\AppData\Local\zig --name test -I D:\a\zig\zig\test -L D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\lib -I D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492\include --zig-lib-dir D:\a\zig\zig\lib --listen=- 
Build Summary: 4974/5205 steps succeeded; 219 skipped; 5 failed; 50527/53261 tests passed; 2734 skipped (disable with --summary none)
test transitive failure
+- test-std transitive failure
   +- run test std-native-znver3-ReleaseFast transitive failure
   |  +- zig test ReleaseFast native failure
   +- run test std-native-znver3-ReleaseFast-libc transitive failure
   |  +- zig test ReleaseFast native failure
   +- run test std-native-znver3-ReleaseFast-single transitive failure
   |  +- zig test ReleaseFast native failure
   +- run test std-native-znver3-ReleaseSafe transitive failure
   |  +- zig test ReleaseSafe native failure
   +- run test std-native-znver3-ReleaseSafe-single transitive failure
      +- zig test ReleaseSafe native failure
error: the following build command failed with exit code 1:
D:\a\zig\zig\zig-cache\o\65004e19c710398b8e79252cc8563193\build.exe D:\a\zig\zig\build-release\stage3-release\bin\zig.exe D:\a\zig\zig D:\a\zig\zig\zig-cache C:\Users\runneradmin\AppData\Local\zig --seed 0x68942a54 test docs --zig-lib-dir D:\a\zig\zig\lib --search-prefix D:\a\zig\zig\zig+llvm+lld+clang-x86_64-windows-gnu-0.12.0-dev.888+130227492 -Dstatic-llvm -Dskip-non-native -Denable-symlinks-windows

It easily reproduces for me locally with LLVM 17.0.4 and this command:

$ stage4/bin/zig test ../lib/std/std.zig -target x86_64-windows-msvc -mcpu=znver3 -OReleaseFast
LLVM Emit Object... zig: /home/andy/Downloads/llvm-project-17/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:714: virtual void {anonymous}::X86AsmBackend::applyFixup(const llvm::MCAssembler&, const llvm::MCFixup&, const llvm::MCValue&, llvm::MutableArrayRef<char>, uint64_t, bool, const llvm::MCSubtargetInfo*) const: Assertion `(Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field"' failed.
Aborted (core dumped)
LLVM Emit Object... zig: /home/andy/Downloads/llvm-project-17/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:714: virtual void {anonymous}::X86AsmBackend::applyFixup(const llvm::MCAssembler&, const llvm::MCFixup&, const llvm::MCValue&, llvm::MutableArrayRef<char>, uint64_t, bool, const llvm::MCSubtargetInfo*) const: Assertion `(Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field"' failed.

Thread 1 "zig" received signal SIGABRT, Aborted.
0x00007ffff7d64adc in __pthread_kill_implementation ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7d64adc in __pthread_kill_implementation ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#1  0x00007ffff7d15cb6 in raise ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#2  0x00007ffff7cff8ba in abort ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#3  0x00007ffff7cff7d9 in __assert_fail_base.cold ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#4  0x00007ffff7d0e9c6 in __assert_fail ()
   from /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6
#5  0x000000000c1103ba in (anonymous namespace)::X86AsmBackend::applyFixup(llvm::MCAssembler const&, llvm::MCFixup const&, llvm::MCValue const&, llvm::MutableArrayRef<char>, unsigned long, bool, llvm::MCSubtargetInfo const*) const ()
#6  0x0000000008e3c060 in llvm::MCAssembler::layout(llvm::MCAsmLayout&) ()
#7  0x0000000008e3c3f5 in llvm::MCAssembler::Finish() ()
#8  0x000000000c4eec16 in llvm::AsmPrinter::doFinalization(llvm::Module&) ()
#9  0x0000000008a4e844 in llvm::FPPassManager::doFinalization(llvm::Module&) ()
#10 0x0000000008a5af84 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#11 0x00000000086fed35 in ZigLLVMTargetMachineEmitToFile ()
#12 0x00000000068bdc7d in codegen.llvm.Object.flushModule (self=0xfada8b0, comp=0xfad7fb0, 
    prog_node=0x7ffffffef5d8) at /home/andy/dev/zig/src/codegen/llvm.zig:1291
#13 0x00000000068c9e8c in link.Coff.flushModule (self=0xfada070, comp=0xfad7fb0, 
    prog_node=0x7ffffffef5d8) at /home/andy/dev/zig/src/link/Coff.zig:1648
#14 0x00000000068c03a7 in link.Coff.lld.linkWithLLD (self=0xfada070, comp=0xfad7fb0, 
    prog_node=0x7ffffffef5d8) at /home/andy/dev/zig/src/link/Coff/lld.zig:34
#15 0x00000000065c4d9b in link.Coff.flush (self=0xfada070, comp=0xfad7fb0, prog_node=0x7ffffffef5d8)
    at /home/andy/dev/zig/src/link/Coff.zig:1635
#16 0x00000000062928f3 in link.File.flush (base=0xfada1c8, comp=0xfad7fb0, prog_node=0x7ffffffef5d8)
    at link.zig:818
#17 0x00000000062921e6 in Compilation.flush (comp=0xfad7fb0, prog_node=0x7ffffffef5d8)
    at Compilation.zig:2398
#18 0x00000000062d5f8d in Compilation.update (comp=0xfad7fb0, main_progress_node=0x7ffffffef5d8)
    at Compilation.zig:2355
#19 0x0000000006304613 in main.updateModule (comp=0xfad7fb0) at main.zig:4279
#20 0x00000000063271dd in main.buildOutputType (gpa=..., arena=..., 
    all_args=7 items at 0xfad6800 = {...}, arg_mode=...) at main.zig:3680
#21 0x00000000061387e8 in main.mainArgs (gpa=..., arena=..., args=7 items at 0xfad6800 = {...})
    at main.zig:285
#22 0x0000000006135846 in main.main () at main.zig:223
(gdb) 

Next steps:

  1. obtain an LLVM IR reduction
  2. file an upstream bug report
  3. figure out how to disable whatever code is failing so the CI turns green
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior os-windows backend-llvm The LLVM backend outputs an LLVM IR Module. labels Nov 6, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Nov 6, 2023
@andrewrk andrewrk added the upstream An issue with a third party project that Zig uses. label Nov 6, 2023
@andrewrk andrewrk modified the milestones: 0.12.0, 0.13.0 Nov 6, 2023
@andrewrk andrewrk changed the title flaky CI test failure: LLVM assertion: Value does not fit in the Fixup field when compiling for znver3, LLVM assertion: Value does not fit in the Fixup field Nov 6, 2023
@andrewrk andrewrk added the arch-x86_64 64-bit x86 label Nov 6, 2023
andrewrk added a commit that referenced this issue Nov 6, 2023
@jacobly0
Copy link
Member

jacobly0 commented Nov 7, 2023

export fn entry() @Vector(2, u64) {
    var a: @Vector(2, u64) = undefined;
    var b: [6]@Vector(2, u64) = undefined;
    for (0..5) |i| b[i] = asm (".fill 49"
        : [_] "=&x" (-> @Vector(2, u64)),
          [_] "=&x" (a),
        : [_] "x" (a),
    );
    for (0..5) |i| a = asm (""
        : [_] "=x" (-> @Vector(2, u64)),
        : [_] "x" (a),
          [_] "x" (b[i]),
    );
    return a;
}
$ zig build-obj repro.zig -target x86_64-windows-msvc -mcpu=znver1 -OReleaseFast
LLVM Emit Object... zig: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:715: virtual void (anonymous namespace)::X86AsmBackend::applyFixup(const MCAssembler &, const MCFixup &, const MCValue &, MutableArrayRef<char>, uint64_t, bool, const MCSubtargetInfo *) const: Assertion `(Size == 0 || isIntN(Size * 8 + 1, SignedValue)) && "Value does not fit in the Fixup field"' failed.
Aborted (core dumped)

@alexrp
Copy link
Member

alexrp commented Aug 28, 2024

This appears fixed in LLVM 19 (the IR for the repro above crashes 18 llc, but not 19).

@alexrp alexrp mentioned this issue Aug 31, 2024
7 tasks
@andrewrk
Copy link
Member Author

Fixed with the merge of LLVM 19 branch in c6ad452.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-x86_64 64-bit x86 backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior os-windows upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants