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

llvm: assertion triggered when casting non-register-sized integer to float #17381

Closed
jacobly0 opened this issue Oct 3, 2023 · 12 comments
Closed
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 upstream An issue with a third party project that Zig uses.
Milestone

Comments

@jacobly0
Copy link
Member

jacobly0 commented Oct 3, 2023

export fn entry() void {
    var a: u15 = 42;
    var b: f32 = @floatFromInt(a);
    _ = b;
}
$ zig build-obj repro.zig -mcpu x86_64+avx512f
LLVM Emit Object... zig: llvm/include/llvm/CodeGen/ValueTypes.h:300: MVT llvm::EVT::getSimpleVT() const: Assertion `isSimple() && "Expected a SimpleValueType!"' failed.
Aborted (core dumped)

This bug is currently triggered by this code when compiling the compiler under the proper circumstances (don't look at the cast direction too closely 🙄).

upstream: llvm/llvm-project#68068

@jacobly0 jacobly0 added bug Observed behavior contradicts documented or intended behavior upstream An issue with a third party project that Zig uses. backend-llvm The LLVM backend outputs an LLVM IR Module. labels Oct 3, 2023
@jacobly0 jacobly0 added this to the 0.12.0 milestone Oct 3, 2023
@jacobly0 jacobly0 added the arch-x86_64 64-bit x86 label Oct 3, 2023
@andrewrk
Copy link
Member

Is this a regression? I notice the fix has not made its way into the release/17.x branch.

@jacobly0
Copy link
Member Author

jacobly0 commented Oct 13, 2023

It has been a bug since at least 16.0.0 15.0.7.

@andrewrk
Copy link
Member

Gotcha, thanks for checking. Pushing a workaround shortly.

@andrewrk
Copy link
Member

Related: #17514

Master branch behavior tests are already tripping another assertion.

@andrewrk
Copy link
Member

andrewrk commented Oct 14, 2023

Workaround landed in ab4d6bf; leaving open to remove the workaround after upgrading to LLVM 18.

@andrewrk andrewrk modified the milestones: 0.12.0, 0.13.0 Oct 14, 2023
@auxiliaire
Copy link

Hi, this is still an issue on master branch with LLVM 18 (from apt.llvm.org, Ubuntu 22.04).

/home/v/Projects/zig/zig/src/zig_llvm.cpp:1350:72: error: ‘WebKit_JS’ is not a member of ‘llvm::CallingConv’
 1350 | static_assert((CallingConv::ID)ZigLLVM_WebKit_JS == llvm::CallingConv::WebKit_JS, "");
      |                                                                        ^~~~~~~~~
make[2]: *** [CMakeFiles/zigcpp.dir/build.make:76: CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:91: CMakeFiles/zigcpp.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Built with: cmake .. -DCMAKE_PREFIX_PATH="/usr/lib/llvm-18;/usr/lib" -DCMAKE_BUILD_TYPE=Release

@nektro
Copy link
Contributor

nektro commented Feb 20, 2024

LLVM 18 isnt released yet

@auxiliaire
Copy link

I can confirm that it works with LLVM 17. This was the source of confusion (from apt.llvm.org):

To install the latest stable version:

bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

Which actually installs LLVM 18.

@nektro
Copy link
Contributor

nektro commented Feb 20, 2024

the error you got is additionally odd because cmake should have told you 18 wasnt allowed much sooner than that assert

@auxiliaire
Copy link

Yeah, I had plenty of such assert. Just quoted the last one. Also had the same error after switching to 14, but that was maybe because I forgot to clean the build dir. I don't know.

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

Fixed with the merge of LLVM 19 branch in c6ad452.

@Rexicon226
Copy link
Contributor

Rexicon226 commented Sep 20, 2024

This should not be closed yet, the test was not re-enabled.
Ignore me, I confused myself with the issue numbers :).

@andrewrk andrewrk reopened this Sep 20, 2024
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 upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants