xref: /linux/tools/objtool/tests/generic/fixtures/cold_function.c (revision 76e7630d90d0d5ff402e06607662b1f9e34eff6c)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Function the compiler may split into a hot part and a foo.cold part. */
3 
4 static const char __modinfo[]
5 	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
6 
7 static void __attribute__((cold, noinline)) slow_path(int x)
8 {
9 	__asm__ volatile("" :: "r"(x));
10 }
11 
12 int target(int x)
13 {
14 	if (__builtin_expect(x < 0, 0))
15 		slow_path(x);
16 #ifdef PATCHED
17 	return x + 2;
18 #else
19 	return x + 1;
20 #endif
21 }
22