0002-weakbugs.diff 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. diff --git a/gcc/cgraph.c b/gcc/cgraph.c
  2. index fcdc02e..db04afd 100644
  3. --- a/gcc/cgraph.c
  4. +++ b/gcc/cgraph.c
  5. @@ -1169,7 +1169,7 @@ cgraph_function_body_availability (struct cgraph_node *node)
  6. inline and offline) having same side effect characteristics as
  7. good optimization is what this optimization is about. */
  8. - else if (!(*targetm.binds_local_p) (node->decl)
  9. + else if ((DECL_WEAK (node->decl) || !(*targetm.binds_local_p) (node->decl))
  10. && !DECL_COMDAT (node->decl) && !DECL_EXTERNAL (node->decl))
  11. avail = AVAIL_OVERWRITABLE;
  12. else avail = AVAIL_AVAILABLE;
  13. @@ -1190,7 +1190,8 @@ cgraph_variable_initializer_availability (struct cgraph_varpool_node *node)
  14. /* If the variable can be overwritten, return OVERWRITABLE. Takes
  15. care of at least two notable extensions - the COMDAT variables
  16. used to share template instantiations in C++. */
  17. - if (!(*targetm.binds_local_p) (node->decl) && !DECL_COMDAT (node->decl))
  18. + if ((DECL_WEAK (node->decl) || !(*targetm.binds_local_p) (node->decl))
  19. + && !DECL_COMDAT (node->decl))
  20. return AVAIL_OVERWRITABLE;
  21. return AVAIL_AVAILABLE;
  22. }
  23. diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
  24. index 84ef830..73d9fcc 100644
  25. --- a/gcc/ipa-inline.c
  26. +++ b/gcc/ipa-inline.c
  27. @@ -300,7 +300,7 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
  28. if (n->inline_decl)
  29. decl = n->inline_decl;
  30. - if (!DECL_INLINE (decl))
  31. + if (!DECL_INLINE (decl) || DECL_WEAK (decl))
  32. {
  33. if (reason)
  34. *reason = N_("function not inlinable");
  35. diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
  36. index fdaff50..1bfd577 100644
  37. --- a/gcc/ipa-pure-const.c
  38. +++ b/gcc/ipa-pure-const.c
  39. @@ -512,7 +512,7 @@ analyze_function (struct cgraph_node *fn)
  40. /* If this function does not return normally or does not bind local,
  41. do not touch this unless it has been marked as const or pure by the
  42. front end. */
  43. - if (TREE_THIS_VOLATILE (decl)
  44. + if (TREE_THIS_VOLATILE (decl) || DECL_WEAK (decl)
  45. || !targetm.binds_local_p (decl))
  46. {
  47. l->pure_const_state = IPA_NEITHER;
  48. diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
  49. index 1c0b79b..5a3ba7e 100644
  50. --- a/gcc/tree-inline.c
  51. +++ b/gcc/tree-inline.c
  52. @@ -1522,6 +1522,8 @@ inlinable_function_p (tree fn)
  53. else if (!DECL_INLINE (fn) && !flag_unit_at_a_time)
  54. inlinable = false;
  55. + else if (DECL_WEAK (fn))
  56. + inlinable = false;
  57. else if (inline_forbidden_p (fn))
  58. {
  59. /* See if we should warn about uninlinable functions. Previously,