-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
@"identifier" syntax accidentally exposes all LLVM intrinsics #2291
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
Comments
@andrewrk any thoughts on this beyond what's already written up in the issue description? I've actually implemented the two mentioned intrinsics as target-specific builtins (needed for something else) before stumbling upon this issue (yeah, I know...). I like the idea of having inline (w)asm, but I'm not quite sure how complicated it would be to accommodate instructions such as pushing/popping off the stack intermingled with the Zig code. I could definitely have a look into that though, perhaps initially focusing only on Oh, and just for the record, branch with the intrinsics as target-specific builtins. |
I think some of the current builtins (like |
Currently the stage1 zig compiler allows access to all LLVM instrinsics if you know what you are doing: ziglang/zig#2291 This is however a bug, and we should use the @prefetch() builtin when availible ziglang/zig#3600.
My immediate though upon seeing the names is to have a |
@shritesh discovered that if you do something like this:
This actually exposes the underlying LLVM intrinsics. #2286 takes advantage of this to provide the global system allocator for the WebAssembly target.
It's definitely problematic to have this behavior and this bug will get fixed, but we can't just pull the rug out. We need a solution for this use case.
Another use case @shritesh pointed out is the NVPTX target: https://llvm.org/docs/NVPTXUsage.html#reading-ptx-special-registers
In the same way WebAssembly needs these intrinsics, NVPTX needs all the ones in the list linked above.
So far, none of the builtin functions of Zig are target-specific. We could start adding target-specific builtins, or we could take a different approach. The current way to do target-specific instructions is inline assembly. We could teach zig about the
(memory.grow)
and(memory.shrink)
wasm instructions and rely onasm
. Zig would detect this pattern and still emit LLVM intrinsics.The text was updated successfully, but these errors were encountered: