void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_block_end_with_switch: NULL case 0"); }
bool ravi_jit_has_errored(ravi_gcc_context_t *ravi) { const char *msg = gcc_jit_context_get_first_error(ravi->context); if (msg) { fprintf(stderr, "JIT error: %s\n", msg); return true; } return false; }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_rvalue_access_field:" " p is not a field of struct foo"); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_context_new_call_through_ptr:" " fn_ptr is not a ptr: (int)42 type: int")); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_context_new_field:" " unknown size for field \"f_opaque\" (type: struct opaque)"); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_rvalue_dereference:" " dereference of non-pointer i (type: int)")); }
ravi_gcc_context_t *ravi_jit_new_context(void) { ravi_gcc_context_t *ravi = NULL; gcc_jit_context *gcc_ctx = gcc_jit_context_acquire(); if (!gcc_ctx) { fprintf(stderr, "failed to allocate a GCC JIT context\n"); goto on_error; } ravi = (ravi_gcc_context_t *)calloc(1, sizeof(ravi_gcc_context_t)); if (!ravi) { fprintf(stderr, "failed to allocate a Ravi JIT context\n"); goto on_error; } ravi->context = gcc_ctx; ravi->auto_ = false; ravi->enabled_ = true; ravi->min_code_size_ = 150; ravi->min_exec_count_ = 50; ravi->opt_level_ = 3; ravi->size_level_ = 0; if (!ravi_setup_lua_types(ravi)) { fprintf(stderr, "failed to setup types\n"); goto on_error; } ravi->parent_result_ = gcc_jit_context_compile(ravi->context); if (gcc_jit_context_get_first_error(ravi->context)) { fprintf(stderr, "aborting due to JIT error: %s\n", gcc_jit_context_get_first_error(ravi->context)); abort(); } return ravi; on_error: if (ravi) { ravi_jit_context_free(ravi); } else if (gcc_ctx) { gcc_jit_context_release(gcc_ctx); } return NULL; }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_context_new_array_access:" " index: \"hello world\" (type: const char *)" " is not of numeric type"); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { /* Ensure that the bad API usage prevents the API giving a bogus result back. */ CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_type_get_vector:" " num_units not a power of two: 7")); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_context_new_function:" " parameter 0 \"i\" (type: int)" " for function fn_two" " was already used for function fn_one")) }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_context_new_function:" " parameter i (type: int)" " is used more than once when creating function" " fn")) }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { /* Ensure that the bad API usage prevents the API giving a bogus result back. */ CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_context_new_function: NULL return_type"); CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt), "gcc_jit_context_new_function: NULL return_type"); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_context_new_call_through_ptr:" " mismatching types for argument 1 of fn_ptr:" " some_fn_ptr:" " assignment to param 1 (type: void *)" " from (int)42 (type: int)")); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { /* Ensure that mismatching arg count leads to the API giving a NULL result back. */ CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_context_new_call:" " not enough arguments to function \"called_function\"" " (got 0 args, expected 1)")); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_context_new_call:" " mismatching types for argument 1" " of function \"called_function\":" " assignment to param ptr (type: struct foo *)" " from f (type: struct foo)"); }
void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { CHECK_VALUE (result, NULL); /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), ("gcc_jit_block_end_with_return:" " rvalue i (type: int)" " has scope limited to function fn_one" " but was used within function fn_two" " (in statement: return i * (int)2;)")); }
int main (int argc, char **argv) { int i, j, k; const int NUM_TOP_ITERATIONS = 2; const int NUM_MIDDLE_ITERATIONS = 2; const int NUM_BOTTOM_ITERATIONS = 2; /* We do the whole thing multiple times to shake out state-management issues in the underlying code. */ for (i = 1; i <= NUM_TOP_ITERATIONS; i++) { /* Create the top-level context. */ snprintf (test, sizeof (test), "%s iteration %d of %d of top level", extract_progname (argv[0]), i, NUM_TOP_ITERATIONS); struct top_level top_level; memset (&top_level, 0, sizeof (top_level)); top_level.ctxt = gcc_jit_context_acquire (); set_options (top_level.ctxt, argv[0]); make_types (&top_level); make_sqrt (&top_level); /* No errors should have occurred. */ CHECK_VALUE (gcc_jit_context_get_first_error (top_level.ctxt), NULL); gcc_jit_context_dump_to_file (top_level.ctxt, "dump-of-test-nested-contexts-top.c", 1); for (j = 1; j <= NUM_MIDDLE_ITERATIONS; j++) { /* Create and populate the middle-level context, using objects from the top-level context. */ snprintf (test, sizeof (test), ("%s iteration %d of %d of top level;" " %d of %d of middle level"), extract_progname (argv[0]), i, NUM_TOP_ITERATIONS, j, NUM_MIDDLE_ITERATIONS); struct middle_level middle_level; memset (&middle_level, 0, sizeof (middle_level)); middle_level.ctxt = gcc_jit_context_new_child_context (top_level.ctxt); make_calc_discriminant (&top_level, &middle_level); /* No errors should have occurred. */ CHECK_VALUE (gcc_jit_context_get_first_error (middle_level.ctxt), NULL); gcc_jit_context_dump_to_file (middle_level.ctxt, "dump-of-test-nested-contexts-middle.c", 1); gcc_jit_result *middle_result = gcc_jit_context_compile (middle_level.ctxt); CHECK_NON_NULL (middle_result); verify_middle_code (middle_level.ctxt, middle_result); for (k = 1; k <= NUM_BOTTOM_ITERATIONS; k++) { /* Create and populate the innermost context, using objects from the top-level and middle-level contexts. */ snprintf (test, sizeof (test), ("%s iteration %d of %d of top level;" " %d of %d of middle level;" " %d of %d of bottom level"), extract_progname (argv[0]), i, NUM_TOP_ITERATIONS, j, NUM_MIDDLE_ITERATIONS, k, NUM_BOTTOM_ITERATIONS); struct bottom_level bottom_level; memset (&bottom_level, 0, sizeof (bottom_level)); bottom_level.ctxt = gcc_jit_context_new_child_context (middle_level.ctxt); make_test_quadratic (&top_level, &middle_level, &bottom_level); /* No errors should have occurred. */ CHECK_VALUE (gcc_jit_context_get_first_error (bottom_level.ctxt), NULL); gcc_jit_context_dump_to_file (bottom_level.ctxt, "dump-of-test-nested-contexts-bottom.c", 1); gcc_jit_result *bottom_result = gcc_jit_context_compile (bottom_level.ctxt); verify_bottom_code (bottom_level.ctxt, bottom_result); gcc_jit_result_release (bottom_result); gcc_jit_context_release (bottom_level.ctxt); } gcc_jit_result_release (middle_result); gcc_jit_context_release (middle_level.ctxt); } gcc_jit_context_release (top_level.ctxt); } totals (); return 0; }