LCOV - code coverage report
Current view: top level - gcc - callback-info.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 40 40
Test Date: 2026-08-22 16:33:35 Functions: 100.0 % 7 7
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Callback attribute summary
       2              :    Copyright (C) 2026 Free Software Foundation, Inc.
       3              :    Contributed by Josef Melcr <jmelcr@gcc.gnu.org>
       4              : 
       5              :    This file is part of GCC.
       6              : 
       7              :    GCC is free software; you can redistribute it and/or modify
       8              :    under the terms of the GNU General Public License as published by
       9              :    the Free Software Foundation; either version 3 of the License, or
      10              :    (at your option) any later version.
      11              : 
      12              :    GCC is distributed in the hope that it will be useful,
      13              :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14              :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15              :    GNU General Public License for more details.
      16              : 
      17              :    You should have received a copy of the GNU General Public License
      18              :    along with GCC; see the file COPYING3.  If not see
      19              :    <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #include "config.h"
      22              : #include "system.h"
      23              : #include "coretypes.h"
      24              : #include "backend.h"
      25              : #include "tree.h"
      26              : #include "gimple.h"
      27              : #include "alloc-pool.h"
      28              : #include "cgraph.h"
      29              : #include "diagnostic.h"
      30              : #include "builtins.h"
      31              : #include "options.h"
      32              : #include "gimple-range.h"
      33              : #include "attribs.h"
      34              : #include "symbol-summary.h"
      35              : #include "data-streamer.h"
      36              : #include "callback-info.h"
      37              : #include "attr-callback.h"
      38              : 
      39              : callback_info_sum_t *callback_info_sum = NULL;
      40              : 
      41              : /* Stream out callback_info.  */
      42              : void
      43           13 : callback_info::stream_out (lto_simple_output_block *ob) const
      44              : {
      45           13 :   streamer_write_uhwi_stream (ob->main_stream, fn_idx);
      46           26 :   streamer_write_uhwi_stream (ob->main_stream, arg_mapping.length ());
      47              : 
      48           52 :   for (int idx : arg_mapping)
      49           13 :     streamer_write_hwi_stream (ob->main_stream, idx);
      50              : 
      51           13 :   bitpack_d bp = bitpack_create (ob->main_stream);
      52           13 :   bp_pack_value (&bp, redirected, 1);
      53           13 :   streamer_write_bitpack (&bp);
      54           13 : }
      55              : 
      56              : /* Stream in callback_info.  */
      57              : void
      58            4 : callback_info::stream_in (lto_input_block *ib)
      59              : {
      60            4 :   fn_idx = streamer_read_uhwi (ib);
      61            4 :   unsigned length = streamer_read_uhwi (ib);
      62            4 :   arg_mapping.reserve (length);
      63              : 
      64           12 :   for (unsigned i = 0; i < length; i++)
      65              :     {
      66            4 :       int idx = streamer_read_hwi (ib);
      67            4 :       arg_mapping.safe_push (idx);
      68              :     }
      69              : 
      70            4 :   bitpack_d bp = streamer_read_bitpack (ib);
      71            4 :   redirected = bp_unpack_value (&bp, 1);
      72            4 : }
      73              : 
      74              : /* Returns the id of the associated callback attribute.  See the comment of the
      75              :    fn_idx field.  */
      76              : unsigned
      77        13358 : callback_info::get_id () const
      78              : {
      79        13358 :   return fn_idx;
      80              : }
      81              : 
      82              : void
      83        15127 : callback_info::init (unsigned fn_idx, tree attr)
      84              : {
      85        15127 :   this->fn_idx = fn_idx;
      86        15127 :   arg_mapping = callback_get_arg_mapping_from_attr (attr);
      87        15127 :   redirected = false;
      88        15127 : }
      89              : 
      90              : /* Populates the callback_info_sum if it's NULL.  */
      91              : void
      92      3318229 : callback_info_sum_t::check_create_info_sum (void)
      93              : {
      94      3318229 :   if (!callback_info_sum)
      95       257567 :     callback_info_sum = new callback_info_sum_t (symtab, false);
      96      3318229 : }
      97              : 
      98              : /* Frees the callback_info_sum pointer.  */
      99              : void
     100       264319 : callback_info_sum_t::free_info_sum (void)
     101              : {
     102       264319 :   if (callback_info_sum)
     103       257168 :     delete callback_info_sum;
     104       264319 :   callback_info_sum = NULL;
     105       264319 : }
     106              : 
     107              : /* Duplication function for the cgraph_edge duplication hook.  */
     108              : void
     109          661 : callback_info_sum_t::duplicate (cgraph_edge *, cgraph_edge *,
     110              :                                 callback_info *src_s, callback_info *dst_s)
     111              : {
     112          661 :   dst_s->fn_idx = src_s->fn_idx;
     113              :   /* Might need to be adjusted in the future, if argument modifications are
     114              :      implemented.  */
     115          661 :   dst_s->arg_mapping = src_s->arg_mapping.copy ();
     116          661 :   dst_s->redirected = src_s->redirected;
     117          661 : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.