-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
codegenDecl on functions overrides all attributes #10682
Labels
Comments
I checked how this is implemented in ccgtypes genProcHeader: Lines 888 to 912 in 2610b16
I'm not sure there is a way to do what is needed in a backward compatible way. I've found the current workaround: proc foo() =
echo 1
{.pragma: hot, codegenDecl: "__attribute__((hot)) N_LIB_PRIVATE N_NIMCALL($#, $#)$#".}
{.pragma: hot_inline, codegenDecl: "__attribute__((hot)) static N_INLINE($#, $#)$#".}
proc bar() {.hot.} =
echo 1
proc baz() {.inline.} =
echo 1
proc oops() {.hot_inline.} =
echo 1
foo()
bar()
baz()
oops() N_LIB_PRIVATE N_NIMCALL(void, foo_ZEVWdPzph9aEvWzKnk2jr4w)(void) {
echoBinSafe(TM_rnFJuQ50wUpy8kftbt2QJA_2, 1);
}
__attribute__((hot)) N_LIB_PRIVATE N_NIMCALL(void, bar_ZEVWdPzph9aEvWzKnk2jr4w_2)(void) {
echoBinSafe(TM_rnFJuQ50wUpy8kftbt2QJA_2, 1);
}
static N_INLINE(void, baz_txURmaVFiHb6ZhpniaNZhgattr_func3)(void) {
echoBinSafe(TM_rnFJuQ50wUpy8kftbt2QJA_2, 1);
}
__attribute__((hot)) static N_INLINE(void, oops_ZEVWdPzph9aEvWzKnk2jr4w_3)(void) {
echoBinSafe(TM_rnFJuQ50wUpy8kftbt2QJA_2, 1);
} |
Removing the low priority tag. We are considering using LLVM Xray for instrumenting Nimbus. void alt_always_instrumented() __attribute__((xray_always_instrument));
void alt_never_instrumented() __attribute__((xray_never_instrument)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
codegenDecl pragma on functions will override all function attributes.
Example:
This produces (in release emode)
In the first case
N_LIB_PRIVATE N_NIMCALL
has been replaced and in the second casestatic N_INLINE
has been replaced.For a bit more context, I'm writing a domain specific compiler in Nim for machine learning and image processing and I need to implement one function per SIMD supported (nothing, SSE, AVX, AVX512, ...). Unfortunately, ideally those should be in separate C files to avoid the compiler using incompatible features in older sets which seems complicated. Alternatively I can use GCC/Clang only attributes like
__attribute__((__target__("avx2")))
.The text was updated successfully, but these errors were encountered: