From d686e07a2900e8fe2c13b58b0a00021ce932e507 Mon Sep 17 00:00:00 2001 From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com> Date: Fri, 18 Nov 2022 09:03:34 +1100 Subject: [PATCH 12/56] Re-add Java (to) comments.
gcc/ChangeLog: * cfgexpand.cc (expand_gimple_basic_block): Re-add Java comment. * gimplify.cc (gimplify_save_expr): Re-add Java to comment. * ipa-utils.h (polymorphic_type_binfo_p): Re-add Java comment. * langhooks.h (struct lang_hooks): Re-add Java to comment. * tree-cfg.cc (verify_gimple_call): Re-add Java comment. * tree-eh.cc (lower_try_finally_switch): Likewise. (lower_resx): Re-add Java to comment. * tree.cc (build_common_builtin_nodes): Likewise. * varasm.cc (assemble_external): Likewise. --- gcc/cfgexpand.cc | 2 ++ gcc/gimplify.cc | 3 ++- gcc/ipa-utils.h | 3 +++ gcc/langhooks.h | 2 +- gcc/tree-cfg.cc | 2 ++ gcc/tree-eh.cc | 8 +++++++- gcc/tree.cc | 2 +- gcc/varasm.cc | 2 +- 8 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index dd29ffffc03..b85934c511a 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -5824,6 +5824,8 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) if (elt) emit_label (*elt); + /* Java emits line number notes in the top of labels. + ??? Make this go away once line number notes are obsoleted. */ BB_HEAD (bb) = NEXT_INSN (last); if (NOTE_P (BB_HEAD (bb))) BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb)); diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 02415cb1b5c..eb562c3a313 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -6447,7 +6447,8 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) /* If the SAVE_EXPR has not been resolved, then evaluate it once. */ if (!SAVE_EXPR_RESOLVED_P (*expr_p)) { - /* The operand may be a void-valued expression. It is + /* The operand may be a void-valued expression such as SAVE_EXPRs + generated by the Java frontend for class initialization. It is being executed only for its side-effects. */ if (TREE_TYPE (val) == void_type_node) { diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 3ca058c0b56..89245263141 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -186,6 +186,9 @@ possible_polymorphic_call_target_p (struct cgraph_edge *e, inline bool polymorphic_type_binfo_p (const_tree binfo) { + /* See if BINFO's type has an virtual table associtated with it. + Check is defensive because of Java FE produces BINFOs + without BINFO_TYPE set. */ return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo)) && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo)))); } diff --git a/gcc/langhooks.h b/gcc/langhooks.h index b1b2b0e10f0..c8f5136d840 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -359,7 +359,7 @@ struct lang_hooks_for_lto struct lang_hooks { /* String identifying the front end and optionally language standard - version, e.g. "GNU C++98". */ + version, e.g. "GNU C++98" or "GNU Java". */ const char *name; /* sizeof (struct lang_identifier), so make_node () creates diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index d982988048f..aa0cd454aa3 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -3470,6 +3470,8 @@ verify_gimple_call (gcall *stmt) && !useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (fntype)) /* ??? At least C++ misses conversions at assignments from void * call results. + ??? Java is completely off. Especially with functions + returning java.lang.Object. For now simply allow arbitrary pointer type conversions. */ && !(POINTER_TYPE_P (TREE_TYPE (lhs)) && POINTER_TYPE_P (TREE_TYPE (fntype)))) diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc index ae8fa21d9a3..fd768913e76 100644 --- a/gcc/tree-eh.cc +++ b/gcc/tree-eh.cc @@ -1564,6 +1564,12 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf) /* Decide whether or not we are going to duplicate the finally block. There are several considerations. + First, if this is Java, then the finally block contains code + written by the user. It has line numbers associated with it, + so duplicating the block means it's difficult to set a breakpoint. + Since controlling code generation via -g is verboten, we simply + never duplicate code without optimization. + Second, we'd like to prevent egregious code growth. One way to do this is to estimate the size of the finally block, multiply that by the number of copies we'd need to make, and compare against @@ -3433,7 +3439,7 @@ lower_resx (basic_block bb, gresx *stmt, _Unwind_Resume library function. */ /* The ARM EABI redefines _Unwind_Resume as __cxa_end_cleanup - with no arguments for C++. Check for that. */ + with no arguments for C++ and Java. Check for that. */ if (src_r->use_cxa_end_cleanup) { fn = builtin_decl_implicit (BUILT_IN_CXA_END_CLEANUP); diff --git a/gcc/tree.cc b/gcc/tree.cc index 254b2373dcf..579001be722 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -9822,7 +9822,7 @@ build_common_builtin_nodes (void) ECF_PURE | ECF_NOTHROW | ECF_LEAF); /* If there's a possibility that we might use the ARM EABI, build the - alternate __cxa_end_cleanup node used to resume from C++. */ + alternate __cxa_end_cleanup node used to resume from C++ and Java. */ if (targetm.arm_eabi_unwinder) { ftype = build_function_type_list (void_type_node, NULL_TREE); diff --git a/gcc/varasm.cc b/gcc/varasm.cc index d0beac8f8e3..4ba8a984ec0 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -2543,7 +2543,7 @@ assemble_external (tree decl ATTRIBUTE_UNUSED) gcc_assert (asm_out_file); /* In a perfect world, the following condition would be true. - Sadly, the Go front end emit assembly *from the front end*, + Sadly, the Java and Go front ends emit assembly *from the front end*, bypassing the call graph. See PR52739. Fix before GCC 4.8. */ #if 0 /* This function should only be called if we are expanding, or have -- 2.38.1