@@ -1891,6 +1891,7 @@ public:
#undef DEF_IDENT
+ static inline int adjust_at_calls_type_main (tree);
static inline int adjust_at_calls_type (tree);
static inline void adjust_at_calls_call (cgraph_edge *, int, tree);
static inline void adjust_at_calls_calls (cgraph_node *);
@@ -2348,15 +2349,51 @@ strub_watermark_parm (tree fndecl)
gcc_unreachable ();
}
+/* Adjust a STRUB_AT_CALLS function TYPE and all its variants,
+ preserving TYPE_ARG_TYPES identity, adding a watermark pointer if
+ it hasn't been added yet. Return the named argument count. */
+
+int
+pass_ipa_strub::adjust_at_calls_type (tree type)
+{
+ gcc_checking_assert (same_strub_mode_in_variants_p (type));
+
+ tree tmain = TYPE_MAIN_VARIANT (type);
+ tree orig_types = TYPE_ARG_TYPES (tmain);
+ gcc_checking_assert (TYPE_ARG_TYPES (type) == orig_types);
+ int named_args = adjust_at_calls_type_main (tmain);
+ tree mod_types = TYPE_ARG_TYPES (tmain);
+
+ if (mod_types != orig_types)
+ for (tree other = TYPE_NEXT_VARIANT (tmain);
+ other != NULL_TREE; other = TYPE_NEXT_VARIANT (other))
+ {
+ gcc_checking_assert (TYPE_ARG_TYPES (other) == orig_types);
+ TYPE_ARG_TYPES (other) = mod_types;
+ }
+
+ if (TYPE_CANONICAL (type)
+ && TYPE_MAIN_VARIANT (TYPE_CANONICAL (type)) != tmain)
+ {
+ int ret = adjust_at_calls_type (TYPE_CANONICAL (type));
+ gcc_checking_assert (named_args == ret);
+ }
+
+ if (flag_checking)
+ verify_type (type);
+
+ return named_args;
+}
+
/* Adjust a STRUB_AT_CALLS function TYPE, adding a watermark pointer if it
hasn't been added yet. Return the named argument count. */
int
-pass_ipa_strub::adjust_at_calls_type (tree type)
+pass_ipa_strub::adjust_at_calls_type_main (tree type)
{
int named_args = 0;
- gcc_checking_assert (same_strub_mode_in_variants_p (type));
+ gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
if (!TYPE_ARG_TYPES (type))
return named_args;
new file mode 100644
@@ -0,0 +1,6 @@
+/* { dg-skip-if part { *-*-* } } */
+void __attribute__((__strub__)) b(int, int) {}
+void c(void);
+int main() {
+ c();
+}
new file mode 100644
@@ -0,0 +1,8 @@
+/* { dg-do link } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto" } */
+/* { dg-additional-sources "strub-pr115848-b.c" } */
+
+typedef void __attribute__((__strub__)) a(int, int);
+a(b);
+void c() { b(0, 0); }