Daily bump.
[official-gcc.git] / gcc / testsuite / jit.dg / test-cold-attribute.c
blob0c76d3e36818a7edcd8c660a7669364d0650bf58
1 /* { dg-do compile { target x86_64-*-* } } */
3 #include <stdlib.h>
4 #include <stdio.h>
6 #include "libgccjit.h"
8 #define TEST_ESCHEWS_SET_OPTIONS
9 static void set_options (gcc_jit_context *ctxt, const char *argv0)
11 // Set "-O2".
12 gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 2);
15 #define TEST_COMPILING_TO_FILE
16 #define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER
17 #define OUTPUT_FILENAME "output-of-test-cold-attribute.c.s"
18 #include "harness.h"
20 void
21 create_code (gcc_jit_context *ctxt, void *user_data)
23 /* Let's try to inject the equivalent of:
24 int
25 __attribute__ ((cold))
26 t()
28 return -1;
32 gcc_jit_type *int_type =
33 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
35 gcc_jit_function *func_t =
36 gcc_jit_context_new_function (ctxt, NULL,
37 GCC_JIT_FUNCTION_EXPORTED,
38 int_type,
39 "t",
40 0, NULL,
41 0);
42 gcc_jit_function_add_attribute(func_t, GCC_JIT_FN_ATTRIBUTE_COLD);
43 gcc_jit_block *block = gcc_jit_function_new_block (func_t, NULL);
44 gcc_jit_rvalue *ret = gcc_jit_context_new_rvalue_from_int (ctxt,
45 int_type,
46 -1);
48 gcc_jit_block_end_with_return (block, NULL, ret);
51 /* { dg-final { jit-verify-output-file-was-created "" } } */
52 /* { dg-final { jit-verify-assembler-output "orl" } } */