+static bool gen_global_function_code(ir_builder *ir, ir_value *global)
+{
+ prog_section_function *fundef;
+ ir_function *irfun;
+
+ irfun = global->constval.vfunc;
+ if (!irfun) {
+ irwarning(global->context, WARN_IMPLICIT_FUNCTION_POINTER,
+ "function `%s` has no body and in QC implicitly becomes a function-pointer", global->name);
+ /* this was a function pointer, don't generate code for those */
+ return true;
+ }
+
+ if (irfun->builtin)
+ return true;
+
+ if (irfun->code_function_def < 0) {
+ irerror(irfun->context, "`%s`: IR global wasn't generated, failed to access function-def", irfun->name);
+ return false;
+ }
+ fundef = &code_functions_data[irfun->code_function_def];
+
+ fundef->entry = code_statements_elements;
+ if (!gen_function_code(irfun)) {
+ irerror(irfun->context, "Failed to generate code for function %s", irfun->name);
+ return false;
+ }
+ return true;
+}
+
+static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal)