1 /* { dg-do compile { target x86_64-*-* } } */
8 #define TEST_ESCHEWS_SET_OPTIONS
9 static void set_options (gcc_jit_context
*ctxt
, const char *argv0
)
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-noinline-attribute.c.s"
21 create_function (gcc_jit_context
*ctxt
,
22 const char *func_name
,
23 gcc_jit_type
*int_type
,
26 gcc_jit_function
*func
27 = gcc_jit_context_new_function(ctxt
, NULL
,
28 GCC_JIT_FUNCTION_INTERNAL
,
33 gcc_jit_block
*block
= gcc_jit_function_new_block (func
, NULL
);
35 gcc_jit_block_add_extended_asm (block
, NULL
, "");
36 gcc_jit_block_end_with_return (block
, NULL
,
37 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, returned_value
));
44 create_code (gcc_jit_context
*ctxt
, void *user_data
)
46 /* Let's try to inject the equivalent of:
47 __attribute__ ((noinline))
48 static int not_removed() {
52 static int removed() {
63 gcc_jit_type
*int_type
=
64 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
66 /* Creating the `not_removed` function. */
67 gcc_jit_function
*not_removed_func
=
68 create_function (ctxt
, "not_removed", int_type
, 1);
69 /* __attribute__ ((no_inline)) */
70 gcc_jit_function_add_attribute(not_removed_func
, GCC_JIT_FN_ATTRIBUTE_NOINLINE
);
72 /* Creating the `removed` function. */
73 gcc_jit_function
*removed_func
=
74 create_function (ctxt
, "removed", int_type
, 2);
76 /* Creating the `foo` function. */
77 gcc_jit_function
*foo_func
=
78 gcc_jit_context_new_function (ctxt
, NULL
,
79 GCC_JIT_FUNCTION_EXPORTED
,
85 gcc_jit_block
*foo_block
= gcc_jit_function_new_block (foo_func
, NULL
);
89 gcc_jit_function_new_local (foo_func
, NULL
, int_type
, "x");
92 gcc_jit_block_add_assignment (
95 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, 0));
98 gcc_jit_block_add_assignment_op (
101 GCC_JIT_BINARY_OP_PLUS
,
102 gcc_jit_context_new_call (ctxt
, NULL
, removed_func
, 0, NULL
));
104 /* x += not_removed(); */
105 gcc_jit_block_add_assignment_op (
108 GCC_JIT_BINARY_OP_PLUS
,
109 gcc_jit_context_new_call (ctxt
, NULL
, not_removed_func
, 0, NULL
));
112 gcc_jit_block_end_with_return (foo_block
, NULL
, gcc_jit_lvalue_as_rvalue(x
));
115 /* { dg-final { jit-verify-output-file-was-created "" } } */
116 /* Check that the "removed" function was inlined, but not the others */
117 /* { dg-final { jit-verify-assembler-output-not ".type\\s+removed.isra.0,\\s+@function" { target { ! *-*-darwin* } } } } */
118 /* { dg-final { jit-verify-assembler-output ".type\\s+not_removed.isra.0,\\s+@function" { target { ! *-*-darwin* } } } } */
119 /* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
121 /* { dg-final { jit-verify-assembler-output-not "\\n_removed.isra.0:" { target *-*-darwin* } } } */
122 /* { dg-final { jit-verify-assembler-output "\\n_not_removed.isra.0:" { target *-*-darwin* } } } */
123 /* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-darwin* } } } */