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

support for GNU C hot+cold label attributes #46831

Open
nickdesaulniers opened this issue Sep 11, 2020 · 3 comments
Open

support for GNU C hot+cold label attributes #46831

nickdesaulniers opened this issue Sep 11, 2020 · 3 comments
Labels
bugzilla Issues migrated from bugzilla c extension:gnu llvm Umbrella label for LLVM issues

Comments

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Sep 11, 2020

Bugzilla Link 47487
Version unspecified
OS All
Blocks #4440
CC @DougGregor,@isanbard,@jyknight,@zygoloid

Extended Description

https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#Label-Attributes
https://godbolt.org/z/Er3rP8

#include <stdio.h>
int foo(void) {
       asm goto ("some asm" : : : : NoError);

/* This branch (the fall-through from the asm) is less commonly used */
ErrorHandling: 
   __attribute__((cold, unused)); /* Semi-colon is required here */
   printf("error\n");
   return 0;

NoError:
   printf("no error\n");
   return 1;
}

clang:

warning: 'cold' attribute only applies to functions [-Wignored-attributes]
   __attribute__((cold, unused)); /* Semi-colon is required here */
                  ^
@nickdesaulniers
Copy link
Member Author

This is going to become a problem for the Linux kernel sooner or later.
https://lore.kernel.org/lkml/20211108164711.mr2cqdcvedin2lvx@treble/

@isanbard
Copy link
Contributor

isanbard commented Nov 9, 2021

Bleck!

That attribute should technically be useless, as the indirect branch from an asm goto block is already marked as "cold", at least in clang.

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Nov 10, 2021

It looks like clang already supports __attribute__((unused)) for -Wunused-label, so this is really just about __attribute__((hot)) and __attribute__((cold)). Re-titling the bug.

That attribute should technically be useless, as the indirect branch from an asm goto block is already marked as "cold", at least in clang.

Things get weird when outputs are involved, but without any I suspect it might be nice to mark which indirect branch is hot or hotter than the fallthrough BB.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Endilll Endilll added the llvm Umbrella label for LLVM issues label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c extension:gnu llvm Umbrella label for LLVM issues
Projects
None yet
Development

No branches or pull requests

3 participants