summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/cold_function.c
blob: f6d410983ce23837af6db42c74e8ca38e18c182c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// SPDX-License-Identifier: GPL-2.0
/* Function the compiler may split into a hot part and a foo.cold part. */

static const char __modinfo[]
	__attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";

static void __attribute__((cold, noinline)) slow_path(int x)
{
	__asm__ volatile("" :: "r"(x));
}

int target(int x)
{
	if (__builtin_expect(x < 0, 0))
		slow_path(x);
#ifdef PATCHED
	return x + 2;
#else
	return x + 1;
#endif
}