aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2017-09-15 16:20:21 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2017-09-15 16:20:21 +0000
commita3e61d61ba546adb2a13b7656e5cc13a1cb17060 (patch)
tree5622929d75f96b1b8b73f3fb8003a4e7ac7b6f8e
parented17cb57b8ddfa4d0c48e0428d0b1df4384a90c5 (diff)
downloadgcc-a3e61d61ba546adb2a13b7656e5cc13a1cb17060.zip
gcc-a3e61d61ba546adb2a13b7656e5cc13a1cb17060.tar.gz
gcc-a3e61d61ba546adb2a13b7656e5cc13a1cb17060.tar.bz2
Add comments to struct cgraph_thunk_info
This commit adds comments to fields in the cgraph_thunk_info structure declaration from cgraph.h. They will hopefully answer questions that people like myself can ask while discovering the thunk machinery. I also made an assertion stricter in cgraph_node::create_thunk. Bootsrapped and regtested on x86_64-linux. gcc/ * cgraph.h (cgraph_thunk_info): Add comments. * cgraph.c (cgraph_node::create_thunk): Adjust comment, make assert for VIRTUAL_* arguments stricter. From-SVN: r252828
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cgraph.c14
-rw-r--r--gcc/cgraph.h39
3 files changed, 50 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7147d5d..b3d3407 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-15 Pierre-Marie de Rodat <derodat@adacore.com>
+
+ * cgraph.h (cgraph_thunk_info): Add comments.
+ * cgraph.c (cgraph_node::create_thunk): Adjust comment, make
+ assert for VIRTUAL_* arguments stricter.
+
2017-09-15 Jackson Woodruff <jackson.woodruff@arm.com>
PR tree-optimization/71026
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 69aa6c5..8bffdec 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -603,7 +603,7 @@ cgraph_node::create_same_body_alias (tree alias, tree decl)
/* Add thunk alias into callgraph. The alias declaration is ALIAS and it
aliases DECL with an adjustments made into the first parameter.
- See comments in thunk_adjust for detail on the parameters. */
+ See comments in struct cgraph_thunk_info for detail on the parameters. */
cgraph_node *
cgraph_node::create_thunk (tree alias, tree, bool this_adjusting,
@@ -619,13 +619,17 @@ cgraph_node::create_thunk (tree alias, tree, bool this_adjusting,
node->reset ();
else
node = cgraph_node::create (alias);
- gcc_checking_assert (!virtual_offset
- || wi::eq_p (virtual_offset, virtual_value));
+
+ /* Make sure that if VIRTUAL_OFFSET is in sync with VIRTUAL_VALUE. */
+ gcc_checking_assert (virtual_offset
+ ? wi::eq_p (virtual_offset, virtual_value)
+ : virtual_value == 0);
+
node->thunk.fixed_offset = fixed_offset;
- node->thunk.this_adjusting = this_adjusting;
node->thunk.virtual_value = virtual_value;
- node->thunk.virtual_offset_p = virtual_offset != NULL;
node->thunk.alias = real_alias;
+ node->thunk.this_adjusting = this_adjusting;
+ node->thunk.virtual_offset_p = virtual_offset != NULL;
node->thunk.thunk_p = true;
node->definition = true;
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 57cdaa4..c668b37 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -629,17 +629,48 @@ extern const char * const cgraph_availability_names[];
extern const char * const ld_plugin_symbol_resolution_names[];
extern const char * const tls_model_names[];
-/* Information about thunk, used only for same body aliases. */
+/* Sub-structure of cgraph_node. Holds information about thunk, used only for
+ same body aliases.
+
+ Thunks are basically wrappers around methods which are introduced in case
+ of multiple inheritance in order to adjust the value of the "this" pointer
+ or of the returned value.
+
+ In the case of this-adjusting thunks, each back-end can override the
+ can_output_mi_thunk/output_mi_thunk target hooks to generate a minimal thunk
+ (with a tail call for instance) directly as assembly. For the default hook
+ or for the case where the can_output_mi_thunk hooks return false, the thunk
+ is gimplified and lowered using the regular machinery. */
struct GTY(()) cgraph_thunk_info {
- /* Information about the thunk. */
+ /* Offset used to adjust "this". */
HOST_WIDE_INT fixed_offset;
+
+ /* Offset in the virtual table to get the offset to adjust "this". Valid iff
+ VIRTUAL_OFFSET_P is true. */
HOST_WIDE_INT virtual_value;
+
+ /* Thunk target, i.e. the method that this thunk wraps. Depending on the
+ TARGET_USE_LOCAL_THUNK_ALIAS_P macro, this may have to be a new alias. */
tree alias;
+
+ /* Nonzero for a "this" adjusting thunk and zero for a result adjusting
+ thunk. */
bool this_adjusting;
+
+ /* If true, this thunk is what we call a virtual thunk. In this case:
+ * for this-adjusting thunks, after the FIXED_OFFSET based adjustment is
+ done, add to the result the offset found in the vtable at:
+ vptr + VIRTUAL_VALUE
+ * for result-adjusting thinks, the FIXED_OFFSET adjustment is done after
+ the virtual one. */
bool virtual_offset_p;
+
+ /* ??? True for special kind of thunks, seems related to instrumentation. */
bool add_pointer_bounds_args;
- /* Set to true when alias node is thunk. */
+
+ /* Set to true when alias node (the cgraph_node to which this struct belong)
+ is a thunk. Access to any other fields is invalid if this is false. */
bool thunk_p;
};
@@ -983,7 +1014,7 @@ public:
/* Add thunk alias into callgraph. The alias declaration is ALIAS and it
aliases DECL with an adjustments made into the first parameter.
- See comments in thunk_adjust for detail on the parameters. */
+ See comments in struct cgraph_thunk_info for detail on the parameters. */
cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
HOST_WIDE_INT fixed_offset,
HOST_WIDE_INT virtual_value,