gcc: Label Attributes

1 
1 6.34 Label Attributes
1 =====================
1 
1 GCC allows attributes to be set on C labels.  ⇒Attribute Syntax,
1 for details of the exact syntax for using attributes.  Other attributes
1 are available for functions (⇒Function Attributes), variables
DONTPRINTYET 1 (⇒Variable Attributes), enumerators (*noteEnumerator
1DONTPRINTYET 1 (⇒Variable Attributes), enumerators (⇒Enumerator

 Attributes), statements (⇒Statement Attributes), and for types
1 (⇒Type Attributes).
1 
1  This example uses the 'cold' label attribute to indicate the
1 'ErrorHandling' branch is unlikely to be taken and that the
1 'ErrorHandling' label is unused:
1 
1 
1         asm goto ("some asm" : : : : NoError);
1 
1      /* This branch (the fall-through from the asm) is less commonly used */
1      ErrorHandling:
1         __attribute__((cold, unused)); /* Semi-colon is required here */
1         printf("error\n");
1         return 0;
1 
1      NoError:
1         printf("no error\n");
1         return 1;
1 
1 'unused'
1      This feature is intended for program-generated code that may
1      contain unused labels, but which is compiled with '-Wall'.  It is
1      not normally appropriate to use in it human-written code, though it
1      could be useful in cases where the code that jumps to the label is
1      contained within an '#ifdef' conditional.
1 
1 'hot'
1      The 'hot' attribute on a label is used to inform the compiler that
1      the path following the label is more likely than paths that are not
1      so annotated.  This attribute is used in cases where
1      '__builtin_expect' cannot be used, for instance with computed goto
1      or 'asm goto'.
1 
1 'cold'
1      The 'cold' attribute on labels is used to inform the compiler that
1      the path following the label is unlikely to be executed.  This
1      attribute is used in cases where '__builtin_expect' cannot be used,
1      for instance with computed goto or 'asm goto'.
1