| 1 |
/* { dg-do compile { target x86_64-*-* } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <stdio.h> |
| 5 |
|
| 6 |
#include "libgccjit.h" |
| 7 |
|
| 8 |
#define TEST_ESCHEWS_SET_OPTIONS |
| 9 |
static void set_options (gcc_jit_context *ctxt, const char *argv0) |
| 10 |
{ |
| 11 |
// Set "-Oz". |
| 12 |
gcc_jit_context_add_command_line_option (ctxt, "-Oz"); |
| 13 |
} |
| 14 |
|
| 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" |
| 19 |
|
| 20 |
void |
| 21 |
create_code (gcc_jit_context *ctxt, void *user_data) |
| 22 |
{ |
| 23 |
/* Let's try to inject the equivalent of: |
| 24 |
int |
| 25 |
__attribute__ ((cold)) |
| 26 |
t() |
| 27 |
{ |
| 28 |
return -1; |
| 29 |
} |
| 30 |
|
| 31 |
*/ |
| 32 |
gcc_jit_type *int_type = |
| 33 |
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); |
| 34 |
|
| 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); |
| 47 |
|
| 48 |
gcc_jit_block_end_with_return (block, NULL, ret); |
| 49 |
} |
| 50 |
|
| 51 |
/* { dg-final { jit-verify-output-file-was-created "" } } */ |
| 52 |
/* { dg-final { jit-verify-assembler-output "orl" } } */ |