LCOV - code coverage report
Current view: top level - gcc - adjust-alignment.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 14 14
Test Date: 2024-04-13 14:00:49 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Adjust alignment for local variable.
       2                 :             :    Copyright (C) 2020-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by Kito Cheng <kito.cheng@sifive.com>
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it under
       8                 :             : the terms of the GNU General Public License as published by the Free
       9                 :             : Software Foundation; either version 3, or (at your option) any later
      10                 :             : version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15                 :             : 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 "target.h"
      26                 :             : #include "tree.h"
      27                 :             : #include "tree-pass.h"
      28                 :             : #include "memmodel.h"
      29                 :             : #include "tm_p.h"
      30                 :             : 
      31                 :             : namespace {
      32                 :             : 
      33                 :             : const pass_data pass_data_adjust_alignment =
      34                 :             : {
      35                 :             :   GIMPLE_PASS, /* type */
      36                 :             :   "adjust_alignment", /* name */
      37                 :             :   OPTGROUP_NONE, /* optinfo_flags */
      38                 :             :   TV_NONE, /* tv_id */
      39                 :             :   0, /* properties_required */
      40                 :             :   0, /* properties_provided */
      41                 :             :   0, /* properties_destroyed */
      42                 :             :   0, /* todo_flags_start */
      43                 :             :   0, /* todo_flags_finish */
      44                 :             : };
      45                 :             : 
      46                 :             : class pass_adjust_alignment : public gimple_opt_pass
      47                 :             : {
      48                 :             : public:
      49                 :      280455 :   pass_adjust_alignment (gcc::context *ctxt)
      50                 :      560910 :     : gimple_opt_pass (pass_data_adjust_alignment, ctxt)
      51                 :             :   {}
      52                 :             : 
      53                 :             :   unsigned int execute (function *) final override;
      54                 :             : }; // class pass_adjust_alignment
      55                 :             : 
      56                 :             : } // anon namespace
      57                 :             : 
      58                 :             : /* Entry point to adjust_alignment pass.  */
      59                 :             : unsigned int
      60                 :     1393019 : pass_adjust_alignment::execute (function *fun)
      61                 :             : {
      62                 :     1393019 :   size_t i;
      63                 :     1393019 :   tree var;
      64                 :             : 
      65                 :     9867287 :   FOR_EACH_LOCAL_DECL (fun, i, var)
      66                 :             :     {
      67                 :             :       /* Don't adjust aligment for static local var and hard register var.  */
      68                 :     7304910 :       if (is_global_var (var) || DECL_HARD_REGISTER (var))
      69                 :      218217 :         continue;
      70                 :             : 
      71                 :     7086693 :       unsigned align = LOCAL_DECL_ALIGNMENT (var);
      72                 :             : 
      73                 :             :       /* Make sure alignment only increase.  */
      74                 :     7086693 :       gcc_assert (align >= DECL_ALIGN (var));
      75                 :             : 
      76                 :     7086693 :       SET_DECL_ALIGN (var, align);
      77                 :             :     }
      78                 :     1393019 :   return 0;
      79                 :             : }
      80                 :             : 
      81                 :             : gimple_opt_pass *
      82                 :      280455 : make_pass_adjust_alignment (gcc::context *ctxt)
      83                 :             : {
      84                 :      280455 :   return new pass_adjust_alignment (ctxt);
      85                 :             : }
        

Generated by: LCOV version 2.1-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.