1 /* Test reduced from use of dynamic_pr_debug on Linux kernel, to verify that
2 we treat the static struct _ddebug as not needing to be tracked by the
3 analyzer, thus optimizing away bloat in the analyzer's state tracking. */
5 /* { dg-do compile { target x86_64-*-* } } */
6 /* { dg-additional-options "-fdump-analyzer-untracked" } */
8 /* Adapted from various files in the Linux kernel, all of which have: */
9 /* SPDX-License-Identifier: GPL-2.0 */
17 typedef struct {} atomic_t
;
19 /* Adapted from include/linux/compiler_attributes.h */
20 #define __always_inline inline __attribute__((__always_inline__))
22 /* Adapted from include/linux/compiler-gcc.h */
23 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
25 /* Adapted from include/linux/jump_label.h, which has: */
29 /* Adapted from arch/x86/include/asm/jump_label.h */
31 static __always_inline
bool arch_static_branch(struct static_key
* const key
, const bool branch
)
33 asm_volatile_goto("1:"
34 : : "i" (key
), "i" (branch
) : : l_yes
);
41 static __always_inline
bool arch_static_branch_jump(struct static_key
* const key
, const bool branch
)
43 asm_volatile_goto("1:"
44 : : "i" (key
), "i" (branch
) : : l_yes
);
51 /* Adapted from include/linux/dynamic_debug.h */
58 unsigned int lineno
:18;
61 struct static_key key
;
62 } __attribute__((aligned(8)));
64 extern void __dynamic_pr_debug(struct _ddebug
*descriptor
, const char *fmt
, ...);
66 static void expanded_dynamic_pr_debug(void) {
68 static struct _ddebug
__attribute__((__aligned__(8)))
69 __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug277
= { /* { dg-warning "track '__UNIQUE_ID_ddebug277': no" } */
72 .format
= ("hello world"),
75 if (arch_static_branch(&__UNIQUE_ID_ddebug277
.key
, false))
76 __dynamic_pr_debug(&__UNIQUE_ID_ddebug277
,