GCC Middle and Back End API Reference
gimple-ssa-warn-alloca.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "tree-pass.h"
#include "ssa.h"
#include "gimple-pretty-print.h"
#include "diagnostic-core.h"
#include "fold-const.h"
#include "gimple-iterator.h"
#include "tree-ssa.h"
#include "tree-cfg.h"
#include "builtins.h"
#include "calls.h"
#include "cfgloop.h"
#include "intl.h"
#include "gimple-range.h"
Include dependency graph for gimple-ssa-warn-alloca.cc:

Data Structures

class  pass_walloca
 
class  alloca_type_and_limit
 

Enumerations

enum  alloca_type {
  ALLOCA_OK , ALLOCA_BOUND_DEFINITELY_LARGE , ALLOCA_BOUND_MAYBE_LARGE , ALLOCA_IN_LOOP ,
  ALLOCA_ARG_IS_ZERO , ALLOCA_UNBOUNDED
}
 

Functions

static unsigned HOST_WIDE_INT adjusted_warn_limit (bool)
 
static bool warn_limit_specified_p (bool is_vla)
 
static class alloca_type_and_limit alloca_call_type (gimple *stmt, bool is_vla)
 
static bool in_loop_p (gimple *stmt)
 
gimple_opt_passmake_pass_walloca (gcc::context *ctxt)
 

Variables

const pass_data pass_data_walloca
 

Enumeration Type Documentation

◆ alloca_type

Enumerator
ALLOCA_OK 
ALLOCA_BOUND_DEFINITELY_LARGE 
ALLOCA_BOUND_MAYBE_LARGE 
ALLOCA_IN_LOOP 
ALLOCA_ARG_IS_ZERO 
ALLOCA_UNBOUNDED 

Function Documentation

◆ adjusted_warn_limit()

static unsigned HOST_WIDE_INT adjusted_warn_limit ( bool idx)
static
Warn on problematic uses of alloca and variable length arrays.
   Copyright (C) 2016-2024 Free Software Foundation, Inc.
   Contributed by Aldy Hernandez <aldyh@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Return the value of the argument N to -Walloca-larger-than= or
-Wvla-larger-than= adjusted for the target data model so that
when N == HOST_WIDE_INT_MAX, the adjusted value is set to
PTRDIFF_MAX on the target.  This is done to prevent warnings
for unknown/unbounded allocations in the "permissive mode"
while still diagnosing excessive and necessarily invalid
allocations.   

References ggc_alloc(), HOST_WIDE_INT_MAX, limits, ptrdiff_type_node, tree_to_shwi(), and TYPE_MAX_VALUE.

Referenced by alloca_call_type(), pass_walloca::execute(), and pass_walloca::gate().

◆ alloca_call_type()

◆ in_loop_p()

◆ make_pass_walloca()

gimple_opt_pass * make_pass_walloca ( gcc::context * ctxt)

References ggc_alloc().

◆ warn_limit_specified_p()

static bool warn_limit_specified_p ( bool is_vla)
static
Return TRUE if the user specified a limit for either VLAs or ALLOCAs.   

References ggc_alloc(), and HOST_WIDE_INT_MAX.

Referenced by alloca_call_type().

Variable Documentation

◆ pass_data_walloca

const pass_data pass_data_walloca
Initial value:
= {
"walloca",
0,
0,
0,
0,
}
@ OPTGROUP_NONE
Definition dumpfile.h:253
@ TV_NONE
Definition timevar.h:76
@ GIMPLE_PASS
Definition tree-pass.h:33
#define PROP_cfg
Definition tree-pass.h:210