-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Proposal: Add never_intrinsify
to std.builtin.CallModifier
#21833
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
Is this phenomenon intrinsically linked to callsites and/or the function boundary? What also looks strange to me is that the linked |
Not in any order, but here would be my counter points:
|
In my understanding (which may be wrong), f.e. in the use case of our own The fact that the compiler is the one emitting the calls (generating callsites) makes it feasible to always specify this as a callsite-attribute,
Probably true, afaiu hand-written assembly already isn't affected by these builtin-replacements? |
That may be true, but:
I think a call modifier strikes a good balance with regards to complexity and usefulness.
I don't quite follow here. The Clang attribute is put on a function, and any code or calls within that function won't be transformed to builtins. It's like if you'd manually written every call in the function as |
Updated description to note that this modifier would still permit inlining at the compiler's discretion like |
I don't quite understand how a call modifier for use with One place where being able to mark a function/block with |
It would help because this is the implementation of the problematic function(s): Lines 60 to 63 in a916bc7
The issue is that LLVM is recognizing the call to Putting |
With regards to the compiler-rt problem you're having, I'm afraid you're a victim of this code: Lines 3210 to 3217 in a916bc7
The attribute needed to get the desired effect here is |
Does the |
LLVM doesn't have a fixed set of predefined attributes. |
The former prevents recognizing code patterns and turning them into libcalls, which is what we want for compiler-rt. The latter is meant to be used on call sites to prevent them from being turned into intrinsics. Context: ziglang#21833
The former prevents recognizing code patterns and turning them into libcalls, which is what we want for compiler-rt. The latter is meant to be used on call sites to prevent them from being turned into intrinsics. Context: ziglang#21833
The former prevents recognizing code patterns and turning them into libcalls, which is what we want for compiler-rt. The latter is meant to be used on call sites to prevent them from being turned into intrinsics. Context: #21833
…tion. From `zig build-exe --help`: -fno-builtin Disable implicit builtin knowledge of functions It seems entirely reasonable and even expected that this option should imply both no-builtins on functions (which disables transformation of recognized code patterns to libcalls) and nobuiltin on call sites (which disables transformation of libcalls to intrinsics). We now match Clang's behavior for -fno-builtin. In both cases, we're painting with a fairly broad brush by applying this to an entire module, but it's better than nothing. ziglang#21833 proposes a more fine-grained way to apply nobuiltin.
…tion. From `zig build-exe --help`: -fno-builtin Disable implicit builtin knowledge of functions It seems entirely reasonable and even expected that this option should imply both no-builtins on functions (which disables transformation of recognized code patterns to libcalls) and nobuiltin on call sites (which disables transformation of libcalls to intrinsics). We now match Clang's behavior for -fno-builtin. In both cases, we're painting with a fairly broad brush by applying this to an entire module, but it's better than nothing. ziglang#21833 proposes a more fine-grained way to apply nobuiltin.
Uh oh!
There was an error while loading. Please reload this page.
This modifier prevents the compiler from turning a function call into an intrinsic/builtin. In other words, when you call a function using this modifier, you're guaranteed to actually get a call to that function in the generated code (note: inlining is still permitted). Concretely, it would map to the
nobuiltin
LLVM attribute at the call site (not to be confused with theno-builtins
function attribute), and whatever equivalent exists for other backends.Motivated by #21831 (and I suspect numerous other cases in compiler-rt if I went digging).
FWIW, Clang has this in the form of the
no_builtin
attribute, so I think it's important that Zig also be able to express this.The text was updated successfully, but these errors were encountered: