public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5005] Improve handling of some builtins.
@ 2021-11-08 17:40 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-11-08 17:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:33a7a63275c959f97b25064cfbe3e7f0dc7f7e9c

commit r12-5005-g33a7a63275c959f97b25064cfbe3e7f0dc7f7e9c
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Mon Nov 8 18:40:17 2021 +0100

    Improve handling of some builtins.
    
    For nested functions we output call to builtin_dwarf_cfa which
    initializes frame entry used only for debugging.  This however
    prevents us from detecting functions containing nested functions
    as const/pure or analyze side effects in modref.
    
    builtin_dwarf_cfa is not documented and I wonder if it should be turned to
    internal function. But I think we could consider functions using it const even
    if in theory one can do things like test the return address and see the
    difference between different frame addreses.
    
    While doing so I also noticed that special_buitin_state handles quite few
    builtins that are not special cased by ipa-modref.  They do not make
    user visible loads/stores and thus I think they shoul dbe annotated by
    ".c" to make this explicit for both modref and PTA.
    
    Finally I aded dwarf_cfa and similar return_address to list of simple
    bulitins since it compiles to simple stack frame load (and we consider
    simple other builtins doing so).
    
            * builtins.c (is_simple_builtin): Add builitin_dwarf_cfa
            and builtin_return_address.
            (builtin_fnspec): Annotate builtin_return,
            bulitin_eh_pointer, builtin_eh_filter, builtin_unwind_resume,
            builtin_cxa_end_cleanup, builtin_eh_copy_values,
            builtin_frame_address, builtin_apply_args,
            builtin_asan_before_dynamic_init, builtin_asan_after_dynamic_init,
            builtin_prefetch, builtin_dwarf_cfa, builtin_return_addrss
            as ".c"
            * ipa-pure-const.c (special_builtin_state): Add builtin_dwarf_cfa
            and builtin_return_address.

Diff:
---
 gcc/builtins.c       | 14 ++++++++++++++
 gcc/ipa-pure-const.c |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 7d0f61fc98b..384864bfb3a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -10711,6 +10711,7 @@ is_simple_builtin (tree decl)
       case BUILT_IN_VA_END:
       case BUILT_IN_STACK_SAVE:
       case BUILT_IN_STACK_RESTORE:
+      case BUILT_IN_DWARF_CFA:
 	/* Exception state returns or moves registers around.  */
       case BUILT_IN_EH_FILTER:
       case BUILT_IN_EH_POINTER:
@@ -11099,6 +11100,19 @@ builtin_fnspec (tree callee)
       CASE_BUILT_IN_TM_STORE (M256):
 	return ".cO ";
       case BUILT_IN_STACK_SAVE:
+      case BUILT_IN_RETURN:
+      case BUILT_IN_EH_POINTER:
+      case BUILT_IN_EH_FILTER:
+      case BUILT_IN_UNWIND_RESUME:
+      case BUILT_IN_CXA_END_CLEANUP:
+      case BUILT_IN_EH_COPY_VALUES:
+      case BUILT_IN_FRAME_ADDRESS:
+      case BUILT_IN_APPLY_ARGS:
+      case BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT:
+      case BUILT_IN_ASAN_AFTER_DYNAMIC_INIT:
+      case BUILT_IN_PREFETCH:
+      case BUILT_IN_DWARF_CFA:
+      case BUILT_IN_RETURN_ADDRESS:
 	return ".c";
       case BUILT_IN_ASSUME_ALIGNED:
 	return "1cX ";
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index a84a4eb7ac0..e5048092939 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -529,6 +529,8 @@ special_builtin_state (enum pure_const_state_e *state, bool *looping,
       case BUILT_IN_APPLY_ARGS:
       case BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT:
       case BUILT_IN_ASAN_AFTER_DYNAMIC_INIT:
+      case BUILT_IN_DWARF_CFA:
+      case BUILT_IN_RETURN_ADDRESS:
 	*looping = false;
 	*state = IPA_CONST;
 	return true;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-08 17:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 17:40 [gcc r12-5005] Improve handling of some builtins Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).