Bug Summary

File:build/gcc/vec.h
Warning:line 741, column 3
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name tree-cfg.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model static -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -resource-dir /usr/lib64/clang/13.0.0 -D IN_GCC -D HAVE_CONFIG_H -I . -I . -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/. -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../include -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcpp/include -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcody -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber/bid -I ../libdecnumber -I /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libbacktrace -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/11/../../../../include/c++/11 -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/11/../../../../include/c++/11/x86_64-suse-linux -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/11/../../../../include/c++/11/backward -internal-isystem /usr/lib64/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-narrowing -Wwrite-strings -Wno-error=format-diag -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fdeprecated-macro -fdebug-compilation-dir=/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -ferror-limit 19 -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=plist-html -analyzer-config silence-checkers=core.NullDereference -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/clang-static-analyzer/2021-11-20-133755-20252-1/report-PolRYC.plist -x c++ /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c

/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c

1/* Control flow functions for trees.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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 "rtl.h"
27#include "tree.h"
28#include "gimple.h"
29#include "cfghooks.h"
30#include "tree-pass.h"
31#include "ssa.h"
32#include "cgraph.h"
33#include "gimple-pretty-print.h"
34#include "diagnostic-core.h"
35#include "fold-const.h"
36#include "trans-mem.h"
37#include "stor-layout.h"
38#include "print-tree.h"
39#include "cfganal.h"
40#include "gimple-fold.h"
41#include "tree-eh.h"
42#include "gimple-iterator.h"
43#include "gimplify-me.h"
44#include "gimple-walk.h"
45#include "tree-cfg.h"
46#include "tree-ssa-loop-manip.h"
47#include "tree-ssa-loop-niter.h"
48#include "tree-into-ssa.h"
49#include "tree-dfa.h"
50#include "tree-ssa.h"
51#include "except.h"
52#include "cfgloop.h"
53#include "tree-ssa-propagate.h"
54#include "value-prof.h"
55#include "tree-inline.h"
56#include "tree-ssa-live.h"
57#include "tree-ssa-dce.h"
58#include "omp-general.h"
59#include "omp-expand.h"
60#include "tree-cfgcleanup.h"
61#include "gimplify.h"
62#include "attribs.h"
63#include "selftest.h"
64#include "opts.h"
65#include "asan.h"
66#include "profile.h"
67
68/* This file contains functions for building the Control Flow Graph (CFG)
69 for a function tree. */
70
71/* Local declarations. */
72
73/* Initial capacity for the basic block array. */
74static const int initial_cfg_capacity = 20;
75
76/* This hash table allows us to efficiently lookup all CASE_LABEL_EXPRs
77 which use a particular edge. The CASE_LABEL_EXPRs are chained together
78 via their CASE_CHAIN field, which we clear after we're done with the
79 hash table to prevent problems with duplication of GIMPLE_SWITCHes.
80
81 Access to this list of CASE_LABEL_EXPRs allows us to efficiently
82 update the case vector in response to edge redirections.
83
84 Right now this table is set up and torn down at key points in the
85 compilation process. It would be nice if we could make the table
86 more persistent. The key is getting notification of changes to
87 the CFG (particularly edge removal, creation and redirection). */
88
89static hash_map<edge, tree> *edge_to_cases;
90
91/* If we record edge_to_cases, this bitmap will hold indexes
92 of basic blocks that end in a GIMPLE_SWITCH which we touched
93 due to edge manipulations. */
94
95static bitmap touched_switch_bbs;
96
97/* OpenMP region idxs for blocks during cfg pass. */
98static vec<int> bb_to_omp_idx;
99
100/* CFG statistics. */
101struct cfg_stats_d
102{
103 long num_merged_labels;
104};
105
106static struct cfg_stats_d cfg_stats;
107
108/* Data to pass to replace_block_vars_by_duplicates_1. */
109struct replace_decls_d
110{
111 hash_map<tree, tree> *vars_map;
112 tree to_context;
113};
114
115/* Hash table to store last discriminator assigned for each locus. */
116struct locus_discrim_map
117{
118 int location_line;
119 int discriminator;
120};
121
122/* Hashtable helpers. */
123
124struct locus_discrim_hasher : free_ptr_hash <locus_discrim_map>
125{
126 static inline hashval_t hash (const locus_discrim_map *);
127 static inline bool equal (const locus_discrim_map *,
128 const locus_discrim_map *);
129};
130
131/* Trivial hash function for a location_t. ITEM is a pointer to
132 a hash table entry that maps a location_t to a discriminator. */
133
134inline hashval_t
135locus_discrim_hasher::hash (const locus_discrim_map *item)
136{
137 return item->location_line;
138}
139
140/* Equality function for the locus-to-discriminator map. A and B
141 point to the two hash table entries to compare. */
142
143inline bool
144locus_discrim_hasher::equal (const locus_discrim_map *a,
145 const locus_discrim_map *b)
146{
147 return a->location_line == b->location_line;
148}
149
150static hash_table<locus_discrim_hasher> *discriminator_per_locus;
151
152/* Basic blocks and flowgraphs. */
153static void make_blocks (gimple_seq);
154
155/* Edges. */
156static void make_edges (void);
157static void assign_discriminators (void);
158static void make_cond_expr_edges (basic_block);
159static void make_gimple_switch_edges (gswitch *, basic_block);
160static bool make_goto_expr_edges (basic_block);
161static void make_gimple_asm_edges (basic_block);
162static edge gimple_redirect_edge_and_branch (edge, basic_block);
163static edge gimple_try_redirect_by_replacing_jump (edge, basic_block);
164
165/* Various helpers. */
166static inline bool stmt_starts_bb_p (gimple *, gimple *);
167static int gimple_verify_flow_info (void);
168static void gimple_make_forwarder_block (edge);
169static gimple *first_non_label_stmt (basic_block);
170static bool verify_gimple_transaction (gtransaction *);
171static bool call_can_make_abnormal_goto (gimple *);
172
173/* Flowgraph optimization and cleanup. */
174static void gimple_merge_blocks (basic_block, basic_block);
175static bool gimple_can_merge_blocks_p (basic_block, basic_block);
176static void remove_bb (basic_block);
177static edge find_taken_edge_computed_goto (basic_block, tree);
178static edge find_taken_edge_cond_expr (const gcond *, tree);
179
180void
181init_empty_tree_cfg_for_function (struct function *fn)
182{
183 /* Initialize the basic block array. */
184 init_flow (fn);
185 profile_status_for_fn (fn)((fn)->cfg->x_profile_status) = PROFILE_ABSENT;
186 n_basic_blocks_for_fn (fn)((fn)->cfg->x_n_basic_blocks) = NUM_FIXED_BLOCKS(2);
187 last_basic_block_for_fn (fn)((fn)->cfg->x_last_basic_block) = NUM_FIXED_BLOCKS(2);
188 vec_safe_grow_cleared (basic_block_info_for_fn (fn)((fn)->cfg->x_basic_block_info),
5
Passing value via 1st parameter 'v'
6
Calling 'vec_safe_grow_cleared<basic_block_def *, va_gc>'
189 initial_cfg_capacity, true);
190
191 /* Build a mapping of labels to their associated blocks. */
192 vec_safe_grow_cleared (label_to_block_map_for_fn (fn)((fn)->cfg->x_label_to_block_map),
193 initial_cfg_capacity, true);
194
195 SET_BASIC_BLOCK_FOR_FN (fn, ENTRY_BLOCK, ENTRY_BLOCK_PTR_FOR_FN (fn))((*((fn)->cfg->x_basic_block_info))[((0))] = (((fn)->
cfg->x_entry_block_ptr)))
;
196 SET_BASIC_BLOCK_FOR_FN (fn, EXIT_BLOCK, EXIT_BLOCK_PTR_FOR_FN (fn))((*((fn)->cfg->x_basic_block_info))[((1))] = (((fn)->
cfg->x_exit_block_ptr)))
;
197
198 ENTRY_BLOCK_PTR_FOR_FN (fn)((fn)->cfg->x_entry_block_ptr)->next_bb
199 = EXIT_BLOCK_PTR_FOR_FN (fn)((fn)->cfg->x_exit_block_ptr);
200 EXIT_BLOCK_PTR_FOR_FN (fn)((fn)->cfg->x_exit_block_ptr)->prev_bb
201 = ENTRY_BLOCK_PTR_FOR_FN (fn)((fn)->cfg->x_entry_block_ptr);
202}
203
204void
205init_empty_tree_cfg (void)
206{
207 init_empty_tree_cfg_for_function (cfun(cfun + 0));
4
Calling 'init_empty_tree_cfg_for_function'
208}
209
210/*---------------------------------------------------------------------------
211 Create basic blocks
212---------------------------------------------------------------------------*/
213
214/* Entry point to the CFG builder for trees. SEQ is the sequence of
215 statements to be added to the flowgraph. */
216
217static void
218build_gimple_cfg (gimple_seq seq)
219{
220 /* Register specific gimple functions. */
221 gimple_register_cfg_hooks ();
222
223 memset ((void *) &cfg_stats, 0, sizeof (cfg_stats));
224
225 init_empty_tree_cfg ();
3
Calling 'init_empty_tree_cfg'
226
227 make_blocks (seq);
228
229 /* Make sure there is always at least one block, even if it's empty. */
230 if (n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks) == NUM_FIXED_BLOCKS(2))
231 create_empty_bb (ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr));
232
233 /* Adjust the size of the array. */
234 if (basic_block_info_for_fn (cfun)(((cfun + 0))->cfg->x_basic_block_info)->length ()
235 < (size_t) n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks))
236 vec_safe_grow_cleared (basic_block_info_for_fn (cfun)(((cfun + 0))->cfg->x_basic_block_info),
237 n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks));
238
239 /* To speed up statement iterator walks, we first purge dead labels. */
240 cleanup_dead_labels ();
241
242 /* Group case nodes to reduce the number of edges.
243 We do this after cleaning up dead labels because otherwise we miss
244 a lot of obvious case merging opportunities. */
245 group_case_labels ();
246
247 /* Create the edges of the flowgraph. */
248 discriminator_per_locus = new hash_table<locus_discrim_hasher> (13);
249 make_edges ();
250 assign_discriminators ();
251 cleanup_dead_labels ();
252 delete discriminator_per_locus;
253 discriminator_per_locus = NULLnullptr;
254}
255
256/* Look for ANNOTATE calls with loop annotation kind in BB; if found, remove
257 them and propagate the information to LOOP. We assume that the annotations
258 come immediately before the condition in BB, if any. */
259
260static void
261replace_loop_annotate_in_block (basic_block bb, class loop *loop)
262{
263 gimple_stmt_iterator gsi = gsi_last_bb (bb);
264 gimple *stmt = gsi_stmt (gsi);
265
266 if (!(stmt && gimple_code (stmt) == GIMPLE_COND))
267 return;
268
269 for (gsi_prev_nondebug (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
270 {
271 stmt = gsi_stmt (gsi);
272 if (gimple_code (stmt) != GIMPLE_CALL)
273 break;
274 if (!gimple_call_internal_p (stmt)
275 || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
276 break;
277
278 switch ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1)))
279 {
280 case annot_expr_ivdep_kind:
281 loop->safelen = INT_MAX2147483647;
282 break;
283 case annot_expr_unroll_kind:
284 loop->unroll
285 = (unsigned short) tree_to_shwi (gimple_call_arg (stmt, 2));
286 cfun(cfun + 0)->has_unroll = true;
287 break;
288 case annot_expr_no_vector_kind:
289 loop->dont_vectorize = true;
290 break;
291 case annot_expr_vector_kind:
292 loop->force_vectorize = true;
293 cfun(cfun + 0)->has_force_vectorize_loops = true;
294 break;
295 case annot_expr_parallel_kind:
296 loop->can_be_parallel = true;
297 loop->safelen = INT_MAX2147483647;
298 break;
299 default:
300 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 300, __FUNCTION__))
;
301 }
302
303 stmt = gimple_build_assign (gimple_call_lhs (stmt),
304 gimple_call_arg (stmt, 0));
305 gsi_replace (&gsi, stmt, true);
306 }
307}
308
309/* Look for ANNOTATE calls with loop annotation kind; if found, remove
310 them and propagate the information to the loop. We assume that the
311 annotations come immediately before the condition of the loop. */
312
313static void
314replace_loop_annotate (void)
315{
316 basic_block bb;
317 gimple_stmt_iterator gsi;
318 gimple *stmt;
319
320 for (auto loop : loops_list (cfun(cfun + 0), 0))
321 {
322 /* First look into the header. */
323 replace_loop_annotate_in_block (loop->header, loop);
324
325 /* Then look into the latch, if any. */
326 if (loop->latch)
327 replace_loop_annotate_in_block (loop->latch, loop);
328
329 /* Push the global flag_finite_loops state down to individual loops. */
330 loop->finite_p = flag_finite_loopsglobal_options.x_flag_finite_loops;
331 }
332
333 /* Remove IFN_ANNOTATE. Safeguard for the case loop->latch == NULL. */
334 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
335 {
336 for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
337 {
338 stmt = gsi_stmt (gsi);
339 if (gimple_code (stmt) != GIMPLE_CALL)
340 continue;
341 if (!gimple_call_internal_p (stmt)
342 || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
343 continue;
344
345 switch ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1)))
346 {
347 case annot_expr_ivdep_kind:
348 case annot_expr_unroll_kind:
349 case annot_expr_no_vector_kind:
350 case annot_expr_vector_kind:
351 case annot_expr_parallel_kind:
352 break;
353 default:
354 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 354, __FUNCTION__))
;
355 }
356
357 warning_at (gimple_location (stmt), 0, "ignoring loop annotation");
358 stmt = gimple_build_assign (gimple_call_lhs (stmt),
359 gimple_call_arg (stmt, 0));
360 gsi_replace (&gsi, stmt, true);
361 }
362 }
363}
364
365static unsigned int
366execute_build_cfg (void)
367{
368 gimple_seq body = gimple_body (current_function_decl);
369
370 build_gimple_cfg (body);
2
Calling 'build_gimple_cfg'
371 gimple_set_body (current_function_decl, NULLnullptr);
372 if (dump_file && (dump_flags & TDF_DETAILS))
373 {
374 fprintf (dump_file, "Scope blocks:\n");
375 dump_scope_blocks (dump_file, dump_flags);
376 }
377 cleanup_tree_cfg ();
378
379 bb_to_omp_idx.release ();
380
381 loop_optimizer_init (AVOID_CFG_MODIFICATIONS(LOOPS_MAY_HAVE_MULTIPLE_LATCHES));
382 replace_loop_annotate ();
383 return 0;
384}
385
386namespace {
387
388const pass_data pass_data_build_cfg =
389{
390 GIMPLE_PASS, /* type */
391 "cfg", /* name */
392 OPTGROUP_NONE, /* optinfo_flags */
393 TV_TREE_CFG, /* tv_id */
394 PROP_gimple_leh(1 << 2), /* properties_required */
395 ( PROP_cfg(1 << 3) | PROP_loops(1 << 11) ), /* properties_provided */
396 0, /* properties_destroyed */
397 0, /* todo_flags_start */
398 0, /* todo_flags_finish */
399};
400
401class pass_build_cfg : public gimple_opt_pass
402{
403public:
404 pass_build_cfg (gcc::context *ctxt)
405 : gimple_opt_pass (pass_data_build_cfg, ctxt)
406 {}
407
408 /* opt_pass methods: */
409 virtual unsigned int execute (function *) { return execute_build_cfg (); }
1
Calling 'execute_build_cfg'
410
411}; // class pass_build_cfg
412
413} // anon namespace
414
415gimple_opt_pass *
416make_pass_build_cfg (gcc::context *ctxt)
417{
418 return new pass_build_cfg (ctxt);
419}
420
421
422/* Return true if T is a computed goto. */
423
424bool
425computed_goto_p (gimple *t)
426{
427 return (gimple_code (t) == GIMPLE_GOTO
428 && TREE_CODE (gimple_goto_dest (t))((enum tree_code) (gimple_goto_dest (t))->base.code) != LABEL_DECL);
429}
430
431/* Returns true if the sequence of statements STMTS only contains
432 a call to __builtin_unreachable (). */
433
434bool
435gimple_seq_unreachable_p (gimple_seq stmts)
436{
437 if (stmts == NULLnullptr
438 /* Return false if -fsanitize=unreachable, we don't want to
439 optimize away those calls, but rather turn them into
440 __ubsan_handle_builtin_unreachable () or __builtin_trap ()
441 later. */
442 || sanitize_flags_p (SANITIZE_UNREACHABLE))
443 return false;
444
445 gimple_stmt_iterator gsi = gsi_last (stmts)gsi_last_1 (&(stmts));
446
447 if (!gimple_call_builtin_p (gsi_stmt (gsi), BUILT_IN_UNREACHABLE))
448 return false;
449
450 for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
451 {
452 gimple *stmt = gsi_stmt (gsi);
453 if (gimple_code (stmt) != GIMPLE_LABEL
454 && !is_gimple_debug (stmt)
455 && !gimple_clobber_p (stmt))
456 return false;
457 }
458 return true;
459}
460
461/* Returns true for edge E where e->src ends with a GIMPLE_COND and
462 the other edge points to a bb with just __builtin_unreachable ().
463 I.e. return true for C->M edge in:
464 <bb C>:
465 ...
466 if (something)
467 goto <bb N>;
468 else
469 goto <bb M>;
470 <bb N>:
471 __builtin_unreachable ();
472 <bb M>: */
473
474bool
475assert_unreachable_fallthru_edge_p (edge e)
476{
477 basic_block pred_bb = e->src;
478 gimple *last = last_stmt (pred_bb);
479 if (last && gimple_code (last) == GIMPLE_COND)
480 {
481 basic_block other_bb = EDGE_SUCC (pred_bb, 0)(*(pred_bb)->succs)[(0)]->dest;
482 if (other_bb == e->dest)
483 other_bb = EDGE_SUCC (pred_bb, 1)(*(pred_bb)->succs)[(1)]->dest;
484 if (EDGE_COUNT (other_bb->succs)vec_safe_length (other_bb->succs) == 0)
485 return gimple_seq_unreachable_p (bb_seq (other_bb));
486 }
487 return false;
488}
489
490
491/* Initialize GF_CALL_CTRL_ALTERING flag, which indicates the call
492 could alter control flow except via eh. We initialize the flag at
493 CFG build time and only ever clear it later. */
494
495static void
496gimple_call_initialize_ctrl_altering (gimple *stmt)
497{
498 int flags = gimple_call_flags (stmt);
499
500 /* A call alters control flow if it can make an abnormal goto. */
501 if (call_can_make_abnormal_goto (stmt)
502 /* A call also alters control flow if it does not return. */
503 || flags & ECF_NORETURN(1 << 3)
504 /* TM ending statements have backedges out of the transaction.
505 Return true so we split the basic block containing them.
506 Note that the TM_BUILTIN test is merely an optimization. */
507 || ((flags & ECF_TM_BUILTIN(1 << 13))
508 && is_tm_ending_fndecl (gimple_call_fndecl (stmt)))
509 /* BUILT_IN_RETURN call is same as return statement. */
510 || gimple_call_builtin_p (stmt, BUILT_IN_RETURN)
511 /* IFN_UNIQUE should be the last insn, to make checking for it
512 as cheap as possible. */
513 || (gimple_call_internal_p (stmt)
514 && gimple_call_internal_unique_p (stmt)))
515 gimple_call_set_ctrl_altering (stmt, true);
516 else
517 gimple_call_set_ctrl_altering (stmt, false);
518}
519
520
521/* Insert SEQ after BB and build a flowgraph. */
522
523static basic_block
524make_blocks_1 (gimple_seq seq, basic_block bb)
525{
526 gimple_stmt_iterator i = gsi_start (seq)gsi_start_1 (&(seq));
527 gimple *stmt = NULLnullptr;
528 gimple *prev_stmt = NULLnullptr;
529 bool start_new_block = true;
530 bool first_stmt_of_seq = true;
531
532 while (!gsi_end_p (i))
533 {
534 /* PREV_STMT should only be set to a debug stmt if the debug
535 stmt is before nondebug stmts. Once stmt reaches a nondebug
536 nonlabel, prev_stmt will be set to it, so that
537 stmt_starts_bb_p will know to start a new block if a label is
538 found. However, if stmt was a label after debug stmts only,
539 keep the label in prev_stmt even if we find further debug
540 stmts, for there may be other labels after them, and they
541 should land in the same block. */
542 if (!prev_stmt || !stmt || !is_gimple_debug (stmt))
543 prev_stmt = stmt;
544 stmt = gsi_stmt (i);
545
546 if (stmt && is_gimple_call (stmt))
547 gimple_call_initialize_ctrl_altering (stmt);
548
549 /* If the statement starts a new basic block or if we have determined
550 in a previous pass that we need to create a new block for STMT, do
551 so now. */
552 if (start_new_block || stmt_starts_bb_p (stmt, prev_stmt))
553 {
554 if (!first_stmt_of_seq)
555 gsi_split_seq_before (&i, &seq);
556 bb = create_basic_block (seq, bb);
557 start_new_block = false;
558 prev_stmt = NULLnullptr;
559 }
560
561 /* Now add STMT to BB and create the subgraphs for special statement
562 codes. */
563 gimple_set_bb (stmt, bb);
564
565 /* If STMT is a basic block terminator, set START_NEW_BLOCK for the
566 next iteration. */
567 if (stmt_ends_bb_p (stmt))
568 {
569 /* If the stmt can make abnormal goto use a new temporary
570 for the assignment to the LHS. This makes sure the old value
571 of the LHS is available on the abnormal edge. Otherwise
572 we will end up with overlapping life-ranges for abnormal
573 SSA names. */
574 if (gimple_has_lhs (stmt)
575 && stmt_can_make_abnormal_goto (stmt)
576 && is_gimple_reg_type (TREE_TYPE (gimple_get_lhs (stmt))((contains_struct_check ((gimple_get_lhs (stmt)), (TS_TYPED),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 576, __FUNCTION__))->typed.type)
))
577 {
578 tree lhs = gimple_get_lhs (stmt);
579 tree tmp = create_tmp_var (TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 579, __FUNCTION__))->typed.type)
);
580 gimple *s = gimple_build_assign (lhs, tmp);
581 gimple_set_location (s, gimple_location (stmt));
582 gimple_set_block (s, gimple_block (stmt));
583 gimple_set_lhs (stmt, tmp);
584 gsi_insert_after (&i, s, GSI_SAME_STMT);
585 }
586 start_new_block = true;
587 }
588
589 gsi_next (&i);
590 first_stmt_of_seq = false;
591 }
592 return bb;
593}
594
595/* Build a flowgraph for the sequence of stmts SEQ. */
596
597static void
598make_blocks (gimple_seq seq)
599{
600 /* Look for debug markers right before labels, and move the debug
601 stmts after the labels. Accepting labels among debug markers
602 adds no value, just complexity; if we wanted to annotate labels
603 with view numbers (so sequencing among markers would matter) or
604 somesuch, we're probably better off still moving the labels, but
605 adding other debug annotations in their original positions or
606 emitting nonbind or bind markers associated with the labels in
607 the original position of the labels.
608
609 Moving labels would probably be simpler, but we can't do that:
610 moving labels assigns label ids to them, and doing so because of
611 debug markers makes for -fcompare-debug and possibly even codegen
612 differences. So, we have to move the debug stmts instead. To
613 that end, we scan SEQ backwards, marking the position of the
614 latest (earliest we find) label, and moving debug stmts that are
615 not separated from it by nondebug nonlabel stmts after the
616 label. */
617 if (MAY_HAVE_DEBUG_MARKER_STMTSglobal_options.x_debug_nonbind_markers_p)
618 {
619 gimple_stmt_iterator label = gsi_none ();
620
621 for (gimple_stmt_iterator i = gsi_last (seq)gsi_last_1 (&(seq)); !gsi_end_p (i); gsi_prev (&i))
622 {
623 gimple *stmt = gsi_stmt (i);
624
625 /* If this is the first label we encounter (latest in SEQ)
626 before nondebug stmts, record its position. */
627 if (is_a <glabel *> (stmt))
628 {
629 if (gsi_end_p (label))
630 label = i;
631 continue;
632 }
633
634 /* Without a recorded label position to move debug stmts to,
635 there's nothing to do. */
636 if (gsi_end_p (label))
637 continue;
638
639 /* Move the debug stmt at I after LABEL. */
640 if (is_gimple_debug (stmt))
641 {
642 gcc_assert (gimple_debug_nonbind_marker_p (stmt))((void)(!(gimple_debug_nonbind_marker_p (stmt)) ? fancy_abort
("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 642, __FUNCTION__), 0 : 0))
;
643 /* As STMT is removed, I advances to the stmt after
644 STMT, so the gsi_prev in the for "increment"
645 expression gets us to the stmt we're to visit after
646 STMT. LABEL, however, would advance to the moved
647 stmt if we passed it to gsi_move_after, so pass it a
648 copy instead, so as to keep LABEL pointing to the
649 LABEL. */
650 gimple_stmt_iterator copy = label;
651 gsi_move_after (&i, &copy);
652 continue;
653 }
654
655 /* There aren't any (more?) debug stmts before label, so
656 there isn't anything else to move after it. */
657 label = gsi_none ();
658 }
659 }
660
661 make_blocks_1 (seq, ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr));
662}
663
664/* Create and return a new empty basic block after bb AFTER. */
665
666static basic_block
667create_bb (void *h, void *e, basic_block after)
668{
669 basic_block bb;
670
671 gcc_assert (!e)((void)(!(!e) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 671, __FUNCTION__), 0 : 0))
;
672
673 /* Create and initialize a new basic block. Since alloc_block uses
674 GC allocation that clears memory to allocate a basic block, we do
675 not have to clear the newly allocated basic block here. */
676 bb = alloc_block ();
677
678 bb->index = last_basic_block_for_fn (cfun)(((cfun + 0))->cfg->x_last_basic_block);
679 bb->flags = BB_NEW;
680 set_bb_seq (bb, h ? (gimple_seq) h : NULLnullptr);
681
682 /* Add the new block to the linked list of blocks. */
683 link_block (bb, after);
684
685 /* Grow the basic block array if needed. */
686 if ((size_t) last_basic_block_for_fn (cfun)(((cfun + 0))->cfg->x_last_basic_block)
687 == basic_block_info_for_fn (cfun)(((cfun + 0))->cfg->x_basic_block_info)->length ())
688 vec_safe_grow_cleared (basic_block_info_for_fn (cfun)(((cfun + 0))->cfg->x_basic_block_info),
689 last_basic_block_for_fn (cfun)(((cfun + 0))->cfg->x_last_basic_block) + 1);
690
691 /* Add the newly created block to the array. */
692 SET_BASIC_BLOCK_FOR_FN (cfun, last_basic_block_for_fn (cfun), bb)((*(((cfun + 0))->cfg->x_basic_block_info))[((((cfun + 0
))->cfg->x_last_basic_block))] = (bb))
;
693
694 n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks)++;
695 last_basic_block_for_fn (cfun)(((cfun + 0))->cfg->x_last_basic_block)++;
696
697 return bb;
698}
699
700
701/*---------------------------------------------------------------------------
702 Edge creation
703---------------------------------------------------------------------------*/
704
705/* If basic block BB has an abnormal edge to a basic block
706 containing IFN_ABNORMAL_DISPATCHER internal call, return
707 that the dispatcher's basic block, otherwise return NULL. */
708
709basic_block
710get_abnormal_succ_dispatcher (basic_block bb)
711{
712 edge e;
713 edge_iterator ei;
714
715 FOR_EACH_EDGE (e, ei, bb->succs)for ((ei) = ei_start_1 (&((bb->succs))); ei_cond ((ei)
, &(e)); ei_next (&(ei)))
716 if ((e->flags & (EDGE_ABNORMAL | EDGE_EH)) == EDGE_ABNORMAL)
717 {
718 gimple_stmt_iterator gsi
719 = gsi_start_nondebug_after_labels_bb (e->dest);
720 gimple *g = gsi_stmt (gsi);
721 if (g && gimple_call_internal_p (g, IFN_ABNORMAL_DISPATCHER))
722 return e->dest;
723 }
724 return NULLnullptr;
725}
726
727/* Helper function for make_edges. Create a basic block with
728 with ABNORMAL_DISPATCHER internal call in it if needed, and
729 create abnormal edges from BBS to it and from it to FOR_BB
730 if COMPUTED_GOTO is false, otherwise factor the computed gotos. */
731
732static void
733handle_abnormal_edges (basic_block *dispatcher_bbs, basic_block for_bb,
734 auto_vec<basic_block> *bbs, bool computed_goto)
735{
736 basic_block *dispatcher = dispatcher_bbs + (computed_goto ? 1 : 0);
737 unsigned int idx = 0;
738 basic_block bb;
739 bool inner = false;
740
741 if (!bb_to_omp_idx.is_empty ())
742 {
743 dispatcher = dispatcher_bbs + 2 * bb_to_omp_idx[for_bb->index];
744 if (bb_to_omp_idx[for_bb->index] != 0)
745 inner = true;
746 }
747
748 /* If the dispatcher has been created already, then there are basic
749 blocks with abnormal edges to it, so just make a new edge to
750 for_bb. */
751 if (*dispatcher == NULLnullptr)
752 {
753 /* Check if there are any basic blocks that need to have
754 abnormal edges to this dispatcher. If there are none, return
755 early. */
756 if (bb_to_omp_idx.is_empty ())
757 {
758 if (bbs->is_empty ())
759 return;
760 }
761 else
762 {
763 FOR_EACH_VEC_ELT (*bbs, idx, bb)for (idx = 0; (*bbs).iterate ((idx), &(bb)); ++(idx))
764 if (bb_to_omp_idx[bb->index] == bb_to_omp_idx[for_bb->index])
765 break;
766 if (bb == NULLnullptr)
767 return;
768 }
769
770 /* Create the dispatcher bb. */
771 *dispatcher = create_basic_block (NULLnullptr, for_bb);
772 if (computed_goto)
773 {
774 /* Factor computed gotos into a common computed goto site. Also
775 record the location of that site so that we can un-factor the
776 gotos after we have converted back to normal form. */
777 gimple_stmt_iterator gsi = gsi_start_bb (*dispatcher);
778
779 /* Create the destination of the factored goto. Each original
780 computed goto will put its desired destination into this
781 variable and jump to the label we create immediately below. */
782 tree var = create_tmp_var (ptr_type_nodeglobal_trees[TI_PTR_TYPE], "gotovar");
783
784 /* Build a label for the new block which will contain the
785 factored computed goto. */
786 tree factored_label_decl
787 = create_artificial_label (UNKNOWN_LOCATION((location_t) 0));
788 gimple *factored_computed_goto_label
789 = gimple_build_label (factored_label_decl);
790 gsi_insert_after (&gsi, factored_computed_goto_label, GSI_NEW_STMT);
791
792 /* Build our new computed goto. */
793 gimple *factored_computed_goto = gimple_build_goto (var);
794 gsi_insert_after (&gsi, factored_computed_goto, GSI_NEW_STMT);
795
796 FOR_EACH_VEC_ELT (*bbs, idx, bb)for (idx = 0; (*bbs).iterate ((idx), &(bb)); ++(idx))
797 {
798 if (!bb_to_omp_idx.is_empty ()
799 && bb_to_omp_idx[bb->index] != bb_to_omp_idx[for_bb->index])
800 continue;
801
802 gsi = gsi_last_bb (bb);
803 gimple *last = gsi_stmt (gsi);
804
805 gcc_assert (computed_goto_p (last))((void)(!(computed_goto_p (last)) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 805, __FUNCTION__), 0 : 0))
;
806
807 /* Copy the original computed goto's destination into VAR. */
808 gimple *assignment
809 = gimple_build_assign (var, gimple_goto_dest (last));
810 gsi_insert_before (&gsi, assignment, GSI_SAME_STMT);
811
812 edge e = make_edge (bb, *dispatcher, EDGE_FALLTHRU);
813 e->goto_locus = gimple_location (last);
814 gsi_remove (&gsi, true);
815 }
816 }
817 else
818 {
819 tree arg = inner ? boolean_true_nodeglobal_trees[TI_BOOLEAN_TRUE] : boolean_false_nodeglobal_trees[TI_BOOLEAN_FALSE];
820 gimple *g = gimple_build_call_internal (IFN_ABNORMAL_DISPATCHER,
821 1, arg);
822 gimple_stmt_iterator gsi = gsi_after_labels (*dispatcher);
823 gsi_insert_after (&gsi, g, GSI_NEW_STMT);
824
825 /* Create predecessor edges of the dispatcher. */
826 FOR_EACH_VEC_ELT (*bbs, idx, bb)for (idx = 0; (*bbs).iterate ((idx), &(bb)); ++(idx))
827 {
828 if (!bb_to_omp_idx.is_empty ()
829 && bb_to_omp_idx[bb->index] != bb_to_omp_idx[for_bb->index])
830 continue;
831 make_edge (bb, *dispatcher, EDGE_ABNORMAL);
832 }
833 }
834 }
835
836 make_edge (*dispatcher, for_bb, EDGE_ABNORMAL);
837}
838
839/* Creates outgoing edges for BB. Returns 1 when it ends with an
840 computed goto, returns 2 when it ends with a statement that
841 might return to this function via an nonlocal goto, otherwise
842 return 0. Updates *PCUR_REGION with the OMP region this BB is in. */
843
844static int
845make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
846{
847 gimple *last = last_stmt (bb);
848 bool fallthru = false;
849 int ret = 0;
850
851 if (!last)
852 return ret;
853
854 switch (gimple_code (last))
855 {
856 case GIMPLE_GOTO:
857 if (make_goto_expr_edges (bb))
858 ret = 1;
859 fallthru = false;
860 break;
861 case GIMPLE_RETURN:
862 {
863 edge e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_exit_block_ptr), 0);
864 e->goto_locus = gimple_location (last);
865 fallthru = false;
866 }
867 break;
868 case GIMPLE_COND:
869 make_cond_expr_edges (bb);
870 fallthru = false;
871 break;
872 case GIMPLE_SWITCH:
873 make_gimple_switch_edges (as_a <gswitch *> (last), bb);
874 fallthru = false;
875 break;
876 case GIMPLE_RESX:
877 make_eh_edges (last);
878 fallthru = false;
879 break;
880 case GIMPLE_EH_DISPATCH:
881 fallthru = make_eh_dispatch_edges (as_a <geh_dispatch *> (last));
882 break;
883
884 case GIMPLE_CALL:
885 /* If this function receives a nonlocal goto, then we need to
886 make edges from this call site to all the nonlocal goto
887 handlers. */
888 if (stmt_can_make_abnormal_goto (last))
889 ret = 2;
890
891 /* If this statement has reachable exception handlers, then
892 create abnormal edges to them. */
893 make_eh_edges (last);
894
895 /* BUILTIN_RETURN is really a return statement. */
896 if (gimple_call_builtin_p (last, BUILT_IN_RETURN))
897 {
898 make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_exit_block_ptr), 0);
899 fallthru = false;
900 }
901 /* Some calls are known not to return. */
902 else
903 fallthru = !gimple_call_noreturn_p (last);
904 break;
905
906 case GIMPLE_ASSIGN:
907 /* A GIMPLE_ASSIGN may throw internally and thus be considered
908 control-altering. */
909 if (is_ctrl_altering_stmt (last))
910 make_eh_edges (last);
911 fallthru = true;
912 break;
913
914 case GIMPLE_ASM:
915 make_gimple_asm_edges (bb);
916 fallthru = true;
917 break;
918
919 CASE_GIMPLE_OMPcase GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: case GIMPLE_OMP_FOR
: case GIMPLE_OMP_SECTIONS: case GIMPLE_OMP_SECTIONS_SWITCH: case
GIMPLE_OMP_SINGLE: case GIMPLE_OMP_TARGET: case GIMPLE_OMP_TEAMS
: case GIMPLE_OMP_SCOPE: case GIMPLE_OMP_SECTION: case GIMPLE_OMP_MASTER
: case GIMPLE_OMP_MASKED: case GIMPLE_OMP_TASKGROUP: case GIMPLE_OMP_ORDERED
: case GIMPLE_OMP_CRITICAL: case GIMPLE_OMP_SCAN: case GIMPLE_OMP_RETURN
: case GIMPLE_OMP_ATOMIC_LOAD: case GIMPLE_OMP_ATOMIC_STORE: case
GIMPLE_OMP_CONTINUE
:
920 fallthru = omp_make_gimple_edges (bb, pcur_region, pomp_index);
921 break;
922
923 case GIMPLE_TRANSACTION:
924 {
925 gtransaction *txn = as_a <gtransaction *> (last);
926 tree label1 = gimple_transaction_label_norm (txn);
927 tree label2 = gimple_transaction_label_uninst (txn);
928
929 if (label1)
930 make_edge (bb, label_to_block (cfun(cfun + 0), label1), EDGE_FALLTHRU);
931 if (label2)
932 make_edge (bb, label_to_block (cfun(cfun + 0), label2),
933 EDGE_TM_UNINSTRUMENTED | (label1 ? 0 : EDGE_FALLTHRU));
934
935 tree label3 = gimple_transaction_label_over (txn);
936 if (gimple_transaction_subcode (txn)
937 & (GTMA_HAVE_ABORT(1u << 2) | GTMA_IS_OUTER(1u << 0)))
938 make_edge (bb, label_to_block (cfun(cfun + 0), label3), EDGE_TM_ABORT);
939
940 fallthru = false;
941 }
942 break;
943
944 default:
945 gcc_assert (!stmt_ends_bb_p (last))((void)(!(!stmt_ends_bb_p (last)) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 945, __FUNCTION__), 0 : 0))
;
946 fallthru = true;
947 break;
948 }
949
950 if (fallthru)
951 make_edge (bb, bb->next_bb, EDGE_FALLTHRU);
952
953 return ret;
954}
955
956/* Join all the blocks in the flowgraph. */
957
958static void
959make_edges (void)
960{
961 basic_block bb;
962 struct omp_region *cur_region = NULLnullptr;
963 auto_vec<basic_block> ab_edge_goto;
964 auto_vec<basic_block> ab_edge_call;
965 int cur_omp_region_idx = 0;
966
967 /* Create an edge from entry to the first block with executable
968 statements in it. */
969 make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr),
970 BASIC_BLOCK_FOR_FN (cfun, NUM_FIXED_BLOCKS)((*(((cfun + 0))->cfg->x_basic_block_info))[((2))]),
971 EDGE_FALLTHRU);
972
973 /* Traverse the basic block array placing edges. */
974 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
975 {
976 int mer;
977
978 if (!bb_to_omp_idx.is_empty ())
979 bb_to_omp_idx[bb->index] = cur_omp_region_idx;
980
981 mer = make_edges_bb (bb, &cur_region, &cur_omp_region_idx);
982 if (mer == 1)
983 ab_edge_goto.safe_push (bb);
984 else if (mer == 2)
985 ab_edge_call.safe_push (bb);
986
987 if (cur_region && bb_to_omp_idx.is_empty ())
988 bb_to_omp_idx.safe_grow_cleared (n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks), true);
989 }
990
991 /* Computed gotos are hell to deal with, especially if there are
992 lots of them with a large number of destinations. So we factor
993 them to a common computed goto location before we build the
994 edge list. After we convert back to normal form, we will un-factor
995 the computed gotos since factoring introduces an unwanted jump.
996 For non-local gotos and abnormal edges from calls to calls that return
997 twice or forced labels, factor the abnormal edges too, by having all
998 abnormal edges from the calls go to a common artificial basic block
999 with ABNORMAL_DISPATCHER internal call and abnormal edges from that
1000 basic block to all forced labels and calls returning twice.
1001 We do this per-OpenMP structured block, because those regions
1002 are guaranteed to be single entry single exit by the standard,
1003 so it is not allowed to enter or exit such regions abnormally this way,
1004 thus all computed gotos, non-local gotos and setjmp/longjmp calls
1005 must not transfer control across SESE region boundaries. */
1006 if (!ab_edge_goto.is_empty () || !ab_edge_call.is_empty ())
1007 {
1008 gimple_stmt_iterator gsi;
1009 basic_block dispatcher_bb_array[2] = { NULLnullptr, NULLnullptr };
1010 basic_block *dispatcher_bbs = dispatcher_bb_array;
1011 int count = n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks);
1012
1013 if (!bb_to_omp_idx.is_empty ())
1014 dispatcher_bbs = XCNEWVEC (basic_block, 2 * count)((basic_block *) xcalloc ((2 * count), sizeof (basic_block)));
1015
1016 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1017 {
1018 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1019 {
1020 glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
1021 tree target;
1022
1023 if (!label_stmt)
1024 break;
1025
1026 target = gimple_label_label (label_stmt);
1027
1028 /* Make an edge to every label block that has been marked as a
1029 potential target for a computed goto or a non-local goto. */
1030 if (FORCED_LABEL (target)((tree_check ((target), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1030, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
)
1031 handle_abnormal_edges (dispatcher_bbs, bb, &ab_edge_goto,
1032 true);
1033 if (DECL_NONLOCAL (target)((contains_struct_check ((target), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1033, __FUNCTION__))->decl_common.nonlocal_flag)
)
1034 {
1035 handle_abnormal_edges (dispatcher_bbs, bb, &ab_edge_call,
1036 false);
1037 break;
1038 }
1039 }
1040
1041 if (!gsi_end_p (gsi) && is_gimple_debug (gsi_stmt (gsi)))
1042 gsi_next_nondebug (&gsi);
1043 if (!gsi_end_p (gsi))
1044 {
1045 /* Make an edge to every setjmp-like call. */
1046 gimple *call_stmt = gsi_stmt (gsi);
1047 if (is_gimple_call (call_stmt)
1048 && ((gimple_call_flags (call_stmt) & ECF_RETURNS_TWICE(1 << 7))
1049 || gimple_call_builtin_p (call_stmt,
1050 BUILT_IN_SETJMP_RECEIVER)))
1051 handle_abnormal_edges (dispatcher_bbs, bb, &ab_edge_call,
1052 false);
1053 }
1054 }
1055
1056 if (!bb_to_omp_idx.is_empty ())
1057 XDELETE (dispatcher_bbs)free ((void*) (dispatcher_bbs));
1058 }
1059
1060 omp_free_regions ();
1061}
1062
1063/* Add SEQ after GSI. Start new bb after GSI, and created further bbs as
1064 needed. Returns true if new bbs were created.
1065 Note: This is transitional code, and should not be used for new code. We
1066 should be able to get rid of this by rewriting all target va-arg
1067 gimplification hooks to use an interface gimple_build_cond_value as described
1068 in https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01194.html. */
1069
1070bool
1071gimple_find_sub_bbs (gimple_seq seq, gimple_stmt_iterator *gsi)
1072{
1073 gimple *stmt = gsi_stmt (*gsi);
1074 basic_block bb = gimple_bb (stmt);
1075 basic_block lastbb, afterbb;
1076 int old_num_bbs = n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks);
1077 edge e;
1078 lastbb = make_blocks_1 (seq, bb);
1079 if (old_num_bbs == n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks))
1080 return false;
1081 e = split_block (bb, stmt);
1082 /* Move e->dest to come after the new basic blocks. */
1083 afterbb = e->dest;
1084 unlink_block (afterbb);
1085 link_block (afterbb, lastbb);
1086 redirect_edge_succ (e, bb->next_bb);
1087 bb = bb->next_bb;
1088 while (bb != afterbb)
1089 {
1090 struct omp_region *cur_region = NULLnullptr;
1091 profile_count cnt = profile_count::zero ();
1092 bool all = true;
1093
1094 int cur_omp_region_idx = 0;
1095 int mer = make_edges_bb (bb, &cur_region, &cur_omp_region_idx);
1096 gcc_assert (!mer && !cur_region)((void)(!(!mer && !cur_region) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1096, __FUNCTION__), 0 : 0))
;
1097 add_bb_to_loop (bb, afterbb->loop_father);
1098
1099 edge e;
1100 edge_iterator ei;
1101 FOR_EACH_EDGE (e, ei, bb->preds)for ((ei) = ei_start_1 (&((bb->preds))); ei_cond ((ei)
, &(e)); ei_next (&(ei)))
1102 {
1103 if (e->count ().initialized_p ())
1104 cnt += e->count ();
1105 else
1106 all = false;
1107 }
1108 tree_guess_outgoing_edge_probabilities (bb);
1109 if (all || profile_status_for_fn (cfun)(((cfun + 0))->cfg->x_profile_status) == PROFILE_READ)
1110 bb->count = cnt;
1111
1112 bb = bb->next_bb;
1113 }
1114 return true;
1115}
1116
1117/* Find the next available discriminator value for LOCUS. The
1118 discriminator distinguishes among several basic blocks that
1119 share a common locus, allowing for more accurate sample-based
1120 profiling. */
1121
1122static int
1123next_discriminator_for_locus (int line)
1124{
1125 struct locus_discrim_map item;
1126 struct locus_discrim_map **slot;
1127
1128 item.location_line = line;
1129 item.discriminator = 0;
1130 slot = discriminator_per_locus->find_slot_with_hash (&item, line, INSERT);
1131 gcc_assert (slot)((void)(!(slot) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1131, __FUNCTION__), 0 : 0))
;
1132 if (*slot == HTAB_EMPTY_ENTRY((void *) 0))
1133 {
1134 *slot = XNEW (struct locus_discrim_map)((struct locus_discrim_map *) xmalloc (sizeof (struct locus_discrim_map
)))
;
1135 gcc_assert (*slot)((void)(!(*slot) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1135, __FUNCTION__), 0 : 0))
;
1136 (*slot)->location_line = line;
1137 (*slot)->discriminator = 0;
1138 }
1139 (*slot)->discriminator++;
1140 return (*slot)->discriminator;
1141}
1142
1143/* Return TRUE if LOCUS1 and LOCUS2 refer to the same source line. */
1144
1145static bool
1146same_line_p (location_t locus1, expanded_location *from, location_t locus2)
1147{
1148 expanded_location to;
1149
1150 if (locus1 == locus2)
1151 return true;
1152
1153 to = expand_location (locus2);
1154
1155 if (from->line != to.line)
1156 return false;
1157 if (from->file == to.file)
1158 return true;
1159 return (from->file != NULLnullptr
1160 && to.file != NULLnullptr
1161 && filename_cmp (from->file, to.file) == 0);
1162}
1163
1164/* Assign discriminators to each basic block. */
1165
1166static void
1167assign_discriminators (void)
1168{
1169 basic_block bb;
1170
1171 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1172 {
1173 edge e;
1174 edge_iterator ei;
1175 gimple *last = last_stmt (bb);
1176 location_t locus = last ? gimple_location (last) : UNKNOWN_LOCATION((location_t) 0);
1177
1178 if (locus == UNKNOWN_LOCATION((location_t) 0))
1179 continue;
1180
1181 expanded_location locus_e = expand_location (locus);
1182
1183 FOR_EACH_EDGE (e, ei, bb->succs)for ((ei) = ei_start_1 (&((bb->succs))); ei_cond ((ei)
, &(e)); ei_next (&(ei)))
1184 {
1185 gimple *first = first_non_label_stmt (e->dest);
1186 gimple *last = last_stmt (e->dest);
1187 if ((first && same_line_p (locus, &locus_e,
1188 gimple_location (first)))
1189 || (last && same_line_p (locus, &locus_e,
1190 gimple_location (last))))
1191 {
1192 if (e->dest->discriminator != 0 && bb->discriminator == 0)
1193 bb->discriminator
1194 = next_discriminator_for_locus (locus_e.line);
1195 else
1196 e->dest->discriminator
1197 = next_discriminator_for_locus (locus_e.line);
1198 }
1199 }
1200 }
1201}
1202
1203/* Create the edges for a GIMPLE_COND starting at block BB. */
1204
1205static void
1206make_cond_expr_edges (basic_block bb)
1207{
1208 gcond *entry = as_a <gcond *> (last_stmt (bb));
1209 gimple *then_stmt, *else_stmt;
1210 basic_block then_bb, else_bb;
1211 tree then_label, else_label;
1212 edge e;
1213
1214 gcc_assert (entry)((void)(!(entry) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1214, __FUNCTION__), 0 : 0))
;
1215 gcc_assert (gimple_code (entry) == GIMPLE_COND)((void)(!(gimple_code (entry) == GIMPLE_COND) ? fancy_abort (
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1215, __FUNCTION__), 0 : 0))
;
1216
1217 /* Entry basic blocks for each component. */
1218 then_label = gimple_cond_true_label (entry);
1219 else_label = gimple_cond_false_label (entry);
1220 then_bb = label_to_block (cfun(cfun + 0), then_label);
1221 else_bb = label_to_block (cfun(cfun + 0), else_label);
1222 then_stmt = first_stmt (then_bb);
1223 else_stmt = first_stmt (else_bb);
1224
1225 e = make_edge (bb, then_bb, EDGE_TRUE_VALUE);
1226 e->goto_locus = gimple_location (then_stmt);
1227 e = make_edge (bb, else_bb, EDGE_FALSE_VALUE);
1228 if (e)
1229 e->goto_locus = gimple_location (else_stmt);
1230
1231 /* We do not need the labels anymore. */
1232 gimple_cond_set_true_label (entry, NULL_TREE(tree) nullptr);
1233 gimple_cond_set_false_label (entry, NULL_TREE(tree) nullptr);
1234}
1235
1236
1237/* Called for each element in the hash table (P) as we delete the
1238 edge to cases hash table.
1239
1240 Clear all the CASE_CHAINs to prevent problems with copying of
1241 SWITCH_EXPRs and structure sharing rules, then free the hash table
1242 element. */
1243
1244bool
1245edge_to_cases_cleanup (edge const &, tree const &value, void *)
1246{
1247 tree t, next;
1248
1249 for (t = value; t; t = next)
1250 {
1251 next = CASE_CHAIN (t)(*((const_cast<tree*> (tree_operand_check (((tree_check
((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1251, __FUNCTION__, (CASE_LABEL_EXPR)))), (3), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1251, __FUNCTION__)))))
;
1252 CASE_CHAIN (t)(*((const_cast<tree*> (tree_operand_check (((tree_check
((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1252, __FUNCTION__, (CASE_LABEL_EXPR)))), (3), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1252, __FUNCTION__)))))
= NULLnullptr;
1253 }
1254
1255 return true;
1256}
1257
1258/* Start recording information mapping edges to case labels. */
1259
1260void
1261start_recording_case_labels (void)
1262{
1263 gcc_assert (edge_to_cases == NULL)((void)(!(edge_to_cases == nullptr) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1263, __FUNCTION__), 0 : 0))
;
1264 edge_to_cases = new hash_map<edge, tree>;
1265 touched_switch_bbs = BITMAP_ALLOCbitmap_alloc (NULLnullptr);
1266}
1267
1268/* Return nonzero if we are recording information for case labels. */
1269
1270static bool
1271recording_case_labels_p (void)
1272{
1273 return (edge_to_cases != NULLnullptr);
1274}
1275
1276/* Stop recording information mapping edges to case labels and
1277 remove any information we have recorded. */
1278void
1279end_recording_case_labels (void)
1280{
1281 bitmap_iterator bi;
1282 unsigned i;
1283 edge_to_cases->traverse<void *, edge_to_cases_cleanup> (NULLnullptr);
1284 delete edge_to_cases;
1285 edge_to_cases = NULLnullptr;
1286 EXECUTE_IF_SET_IN_BITMAP (touched_switch_bbs, 0, i, bi)for (bmp_iter_set_init (&(bi), (touched_switch_bbs), (0),
&(i)); bmp_iter_set (&(bi), &(i)); bmp_iter_next
(&(bi), &(i)))
1287 {
1288 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, i)((*(((cfun + 0))->cfg->x_basic_block_info))[(i)]);
1289 if (bb)
1290 {
1291 gimple *stmt = last_stmt (bb);
1292 if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
1293 group_case_labels_stmt (as_a <gswitch *> (stmt));
1294 }
1295 }
1296 BITMAP_FREE (touched_switch_bbs)((void) (bitmap_obstack_free ((bitmap) touched_switch_bbs), (
touched_switch_bbs) = (bitmap) nullptr))
;
1297}
1298
1299/* If we are inside a {start,end}_recording_cases block, then return
1300 a chain of CASE_LABEL_EXPRs from T which reference E.
1301
1302 Otherwise return NULL. */
1303
1304static tree
1305get_cases_for_edge (edge e, gswitch *t)
1306{
1307 tree *slot;
1308 size_t i, n;
1309
1310 /* If we are not recording cases, then we do not have CASE_LABEL_EXPR
1311 chains available. Return NULL so the caller can detect this case. */
1312 if (!recording_case_labels_p ())
1313 return NULLnullptr;
1314
1315 slot = edge_to_cases->get (e);
1316 if (slot)
1317 return *slot;
1318
1319 /* If we did not find E in the hash table, then this must be the first
1320 time we have been queried for information about E & T. Add all the
1321 elements from T to the hash table then perform the query again. */
1322
1323 n = gimple_switch_num_labels (t);
1324 for (i = 0; i < n; i++)
1325 {
1326 tree elt = gimple_switch_label (t, i);
1327 tree lab = CASE_LABEL (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1327, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1327, __FUNCTION__)))))
;
1328 basic_block label_bb = label_to_block (cfun(cfun + 0), lab);
1329 edge this_edge = find_edge (e->src, label_bb);
1330
1331 /* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create
1332 a new chain. */
1333 tree &s = edge_to_cases->get_or_insert (this_edge);
1334 CASE_CHAIN (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1334, __FUNCTION__, (CASE_LABEL_EXPR)))), (3), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1334, __FUNCTION__)))))
= s;
1335 s = elt;
1336 }
1337
1338 return *edge_to_cases->get (e);
1339}
1340
1341/* Create the edges for a GIMPLE_SWITCH starting at block BB. */
1342
1343static void
1344make_gimple_switch_edges (gswitch *entry, basic_block bb)
1345{
1346 size_t i, n;
1347
1348 n = gimple_switch_num_labels (entry);
1349
1350 for (i = 0; i < n; ++i)
1351 {
1352 basic_block label_bb = gimple_switch_label_bb (cfun(cfun + 0), entry, i);
1353 make_edge (bb, label_bb, 0);
1354 }
1355}
1356
1357
1358/* Return the basic block holding label DEST. */
1359
1360basic_block
1361label_to_block (struct function *ifun, tree dest)
1362{
1363 int uid = LABEL_DECL_UID (dest)((tree_check ((dest), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1363, __FUNCTION__, (LABEL_DECL)))->label_decl.label_decl_uid
)
;
1364
1365 /* We would die hard when faced by an undefined label. Emit a label to
1366 the very first basic block. This will hopefully make even the dataflow
1367 and undefined variable warnings quite right. */
1368 if (seen_error () && uid < 0)
1369 {
1370 gimple_stmt_iterator gsi =
1371 gsi_start_bb (BASIC_BLOCK_FOR_FN (cfun, NUM_FIXED_BLOCKS)((*(((cfun + 0))->cfg->x_basic_block_info))[((2))]));
1372 gimple *stmt;
1373
1374 stmt = gimple_build_label (dest);
1375 gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
1376 uid = LABEL_DECL_UID (dest)((tree_check ((dest), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1376, __FUNCTION__, (LABEL_DECL)))->label_decl.label_decl_uid
)
;
1377 }
1378 if (vec_safe_length (ifun->cfg->x_label_to_block_map) <= (unsigned int) uid)
1379 return NULLnullptr;
1380 return (*ifun->cfg->x_label_to_block_map)[uid];
1381}
1382
1383/* Create edges for a goto statement at block BB. Returns true
1384 if abnormal edges should be created. */
1385
1386static bool
1387make_goto_expr_edges (basic_block bb)
1388{
1389 gimple_stmt_iterator last = gsi_last_bb (bb);
1390 gimple *goto_t = gsi_stmt (last);
1391
1392 /* A simple GOTO creates normal edges. */
1393 if (simple_goto_p (goto_t))
1394 {
1395 tree dest = gimple_goto_dest (goto_t);
1396 basic_block label_bb = label_to_block (cfun(cfun + 0), dest);
1397 edge e = make_edge (bb, label_bb, EDGE_FALLTHRU);
1398 e->goto_locus = gimple_location (goto_t);
1399 gsi_remove (&last, true);
1400 return false;
1401 }
1402
1403 /* A computed GOTO creates abnormal edges. */
1404 return true;
1405}
1406
1407/* Create edges for an asm statement with labels at block BB. */
1408
1409static void
1410make_gimple_asm_edges (basic_block bb)
1411{
1412 gasm *stmt = as_a <gasm *> (last_stmt (bb));
1413 int i, n = gimple_asm_nlabels (stmt);
1414
1415 for (i = 0; i < n; ++i)
1416 {
1417 tree label = TREE_VALUE (gimple_asm_label_op (stmt, i))((tree_check ((gimple_asm_label_op (stmt, i)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1417, __FUNCTION__, (TREE_LIST)))->list.value)
;
1418 basic_block label_bb = label_to_block (cfun(cfun + 0), label);
1419 make_edge (bb, label_bb, 0);
1420 }
1421}
1422
1423/*---------------------------------------------------------------------------
1424 Flowgraph analysis
1425---------------------------------------------------------------------------*/
1426
1427/* Cleanup useless labels in basic blocks. This is something we wish
1428 to do early because it allows us to group case labels before creating
1429 the edges for the CFG, and it speeds up block statement iterators in
1430 all passes later on.
1431 We rerun this pass after CFG is created, to get rid of the labels that
1432 are no longer referenced. After then we do not run it any more, since
1433 (almost) no new labels should be created. */
1434
1435/* A map from basic block index to the leading label of that block. */
1436struct label_record
1437{
1438 /* The label. */
1439 tree label;
1440
1441 /* True if the label is referenced from somewhere. */
1442 bool used;
1443};
1444
1445/* Given LABEL return the first label in the same basic block. */
1446
1447static tree
1448main_block_label (tree label, label_record *label_for_bb)
1449{
1450 basic_block bb = label_to_block (cfun(cfun + 0), label);
1451 tree main_label = label_for_bb[bb->index].label;
1452
1453 /* label_to_block possibly inserted undefined label into the chain. */
1454 if (!main_label)
1455 {
1456 label_for_bb[bb->index].label = label;
1457 main_label = label;
1458 }
1459
1460 label_for_bb[bb->index].used = true;
1461 return main_label;
1462}
1463
1464/* Clean up redundant labels within the exception tree. */
1465
1466static void
1467cleanup_dead_labels_eh (label_record *label_for_bb)
1468{
1469 eh_landing_pad lp;
1470 eh_region r;
1471 tree lab;
1472 int i;
1473
1474 if (cfun(cfun + 0)->eh == NULLnullptr)
1475 return;
1476
1477 for (i = 1; vec_safe_iterate (cfun(cfun + 0)->eh->lp_array, i, &lp); ++i)
1478 if (lp && lp->post_landing_pad)
1479 {
1480 lab = main_block_label (lp->post_landing_pad, label_for_bb);
1481 if (lab != lp->post_landing_pad)
1482 {
1483 EH_LANDING_PAD_NR (lp->post_landing_pad)((tree_check ((lp->post_landing_pad), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1483, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
)
= 0;
1484 lp->post_landing_pad = lab;
1485 EH_LANDING_PAD_NR (lab)((tree_check ((lab), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1485, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
)
= lp->index;
1486 }
1487 }
1488
1489 FOR_ALL_EH_REGION (r)for ((r) = ((cfun + 0))->eh->region_tree; (r) != nullptr
; (r) = ehr_next (r, nullptr))
1490 switch (r->type)
1491 {
1492 case ERT_CLEANUP:
1493 case ERT_MUST_NOT_THROW:
1494 break;
1495
1496 case ERT_TRY:
1497 {
1498 eh_catch c;
1499 for (c = r->u.eh_try.first_catch; c ; c = c->next_catch)
1500 {
1501 lab = c->label;
1502 if (lab)
1503 c->label = main_block_label (lab, label_for_bb);
1504 }
1505 }
1506 break;
1507
1508 case ERT_ALLOWED_EXCEPTIONS:
1509 lab = r->u.allowed.label;
1510 if (lab)
1511 r->u.allowed.label = main_block_label (lab, label_for_bb);
1512 break;
1513 }
1514}
1515
1516
1517/* Cleanup redundant labels. This is a three-step process:
1518 1) Find the leading label for each block.
1519 2) Redirect all references to labels to the leading labels.
1520 3) Cleanup all useless labels. */
1521
1522void
1523cleanup_dead_labels (void)
1524{
1525 basic_block bb;
1526 label_record *label_for_bb = XCNEWVEC (struct label_record,((struct label_record *) xcalloc (((((cfun + 0))->cfg->
x_last_basic_block)), sizeof (struct label_record)))
1527 last_basic_block_for_fn (cfun))((struct label_record *) xcalloc (((((cfun + 0))->cfg->
x_last_basic_block)), sizeof (struct label_record)))
;
1528
1529 /* Find a suitable label for each block. We use the first user-defined
1530 label if there is one, or otherwise just the first label we see. */
1531 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1532 {
1533 gimple_stmt_iterator i;
1534
1535 for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
1536 {
1537 tree label;
1538 glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
1539
1540 if (!label_stmt)
1541 break;
1542
1543 label = gimple_label_label (label_stmt);
1544
1545 /* If we have not yet seen a label for the current block,
1546 remember this one and see if there are more labels. */
1547 if (!label_for_bb[bb->index].label)
1548 {
1549 label_for_bb[bb->index].label = label;
1550 continue;
1551 }
1552
1553 /* If we did see a label for the current block already, but it
1554 is an artificially created label, replace it if the current
1555 label is a user defined label. */
1556 if (!DECL_ARTIFICIAL (label)((contains_struct_check ((label), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1556, __FUNCTION__))->decl_common.artificial_flag)
1557 && DECL_ARTIFICIAL (label_for_bb[bb->index].label)((contains_struct_check ((label_for_bb[bb->index].label), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1557, __FUNCTION__))->decl_common.artificial_flag)
)
1558 {
1559 label_for_bb[bb->index].label = label;
1560 break;
1561 }
1562 }
1563 }
1564
1565 /* Now redirect all jumps/branches to the selected label.
1566 First do so for each block ending in a control statement. */
1567 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1568 {
1569 gimple *stmt = last_stmt (bb);
1570 tree label, new_label;
1571
1572 if (!stmt)
1573 continue;
1574
1575 switch (gimple_code (stmt))
1576 {
1577 case GIMPLE_COND:
1578 {
1579 gcond *cond_stmt = as_a <gcond *> (stmt);
1580 label = gimple_cond_true_label (cond_stmt);
1581 if (label)
1582 {
1583 new_label = main_block_label (label, label_for_bb);
1584 if (new_label != label)
1585 gimple_cond_set_true_label (cond_stmt, new_label);
1586 }
1587
1588 label = gimple_cond_false_label (cond_stmt);
1589 if (label)
1590 {
1591 new_label = main_block_label (label, label_for_bb);
1592 if (new_label != label)
1593 gimple_cond_set_false_label (cond_stmt, new_label);
1594 }
1595 }
1596 break;
1597
1598 case GIMPLE_SWITCH:
1599 {
1600 gswitch *switch_stmt = as_a <gswitch *> (stmt);
1601 size_t i, n = gimple_switch_num_labels (switch_stmt);
1602
1603 /* Replace all destination labels. */
1604 for (i = 0; i < n; ++i)
1605 {
1606 tree case_label = gimple_switch_label (switch_stmt, i);
1607 label = CASE_LABEL (case_label)(*((const_cast<tree*> (tree_operand_check (((tree_check
((case_label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1607, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1607, __FUNCTION__)))))
;
1608 new_label = main_block_label (label, label_for_bb);
1609 if (new_label != label)
1610 CASE_LABEL (case_label)(*((const_cast<tree*> (tree_operand_check (((tree_check
((case_label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1610, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1610, __FUNCTION__)))))
= new_label;
1611 }
1612 break;
1613 }
1614
1615 case GIMPLE_ASM:
1616 {
1617 gasm *asm_stmt = as_a <gasm *> (stmt);
1618 int i, n = gimple_asm_nlabels (asm_stmt);
1619
1620 for (i = 0; i < n; ++i)
1621 {
1622 tree cons = gimple_asm_label_op (asm_stmt, i);
1623 tree label = main_block_label (TREE_VALUE (cons)((tree_check ((cons), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1623, __FUNCTION__, (TREE_LIST)))->list.value)
, label_for_bb);
1624 TREE_VALUE (cons)((tree_check ((cons), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1624, __FUNCTION__, (TREE_LIST)))->list.value)
= label;
1625 }
1626 break;
1627 }
1628
1629 /* We have to handle gotos until they're removed, and we don't
1630 remove them until after we've created the CFG edges. */
1631 case GIMPLE_GOTO:
1632 if (!computed_goto_p (stmt))
1633 {
1634 ggoto *goto_stmt = as_a <ggoto *> (stmt);
1635 label = gimple_goto_dest (goto_stmt);
1636 new_label = main_block_label (label, label_for_bb);
1637 if (new_label != label)
1638 gimple_goto_set_dest (goto_stmt, new_label);
1639 }
1640 break;
1641
1642 case GIMPLE_TRANSACTION:
1643 {
1644 gtransaction *txn = as_a <gtransaction *> (stmt);
1645
1646 label = gimple_transaction_label_norm (txn);
1647 if (label)
1648 {
1649 new_label = main_block_label (label, label_for_bb);
1650 if (new_label != label)
1651 gimple_transaction_set_label_norm (txn, new_label);
1652 }
1653
1654 label = gimple_transaction_label_uninst (txn);
1655 if (label)
1656 {
1657 new_label = main_block_label (label, label_for_bb);
1658 if (new_label != label)
1659 gimple_transaction_set_label_uninst (txn, new_label);
1660 }
1661
1662 label = gimple_transaction_label_over (txn);
1663 if (label)
1664 {
1665 new_label = main_block_label (label, label_for_bb);
1666 if (new_label != label)
1667 gimple_transaction_set_label_over (txn, new_label);
1668 }
1669 }
1670 break;
1671
1672 default:
1673 break;
1674 }
1675 }
1676
1677 /* Do the same for the exception region tree labels. */
1678 cleanup_dead_labels_eh (label_for_bb);
1679
1680 /* Finally, purge dead labels. All user-defined labels and labels that
1681 can be the target of non-local gotos and labels which have their
1682 address taken are preserved. */
1683 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1684 {
1685 gimple_stmt_iterator i;
1686 tree label_for_this_bb = label_for_bb[bb->index].label;
1687
1688 if (!label_for_this_bb)
1689 continue;
1690
1691 /* If the main label of the block is unused, we may still remove it. */
1692 if (!label_for_bb[bb->index].used)
1693 label_for_this_bb = NULLnullptr;
1694
1695 for (i = gsi_start_bb (bb); !gsi_end_p (i); )
1696 {
1697 tree label;
1698 glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
1699
1700 if (!label_stmt)
1701 break;
1702
1703 label = gimple_label_label (label_stmt);
1704
1705 if (label == label_for_this_bb
1706 || !DECL_ARTIFICIAL (label)((contains_struct_check ((label), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1706, __FUNCTION__))->decl_common.artificial_flag)
1707 || DECL_NONLOCAL (label)((contains_struct_check ((label), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1707, __FUNCTION__))->decl_common.nonlocal_flag)
1708 || FORCED_LABEL (label)((tree_check ((label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1708, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
)
1709 gsi_next (&i);
1710 else
1711 {
1712 gcc_checking_assert (EH_LANDING_PAD_NR (label) == 0)((void)(!(((tree_check ((label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1712, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
) == 0) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1712, __FUNCTION__), 0 : 0))
;
1713 gsi_remove (&i, true);
1714 }
1715 }
1716 }
1717
1718 free (label_for_bb);
1719}
1720
1721/* Scan the sorted vector of cases in STMT (a GIMPLE_SWITCH) and combine
1722 the ones jumping to the same label.
1723 Eg. three separate entries 1: 2: 3: become one entry 1..3: */
1724
1725bool
1726group_case_labels_stmt (gswitch *stmt)
1727{
1728 int old_size = gimple_switch_num_labels (stmt);
1729 int i, next_index, new_size;
1730 basic_block default_bb = NULLnullptr;
1731 hash_set<tree> *removed_labels = NULLnullptr;
1732
1733 default_bb = gimple_switch_default_bb (cfun(cfun + 0), stmt);
1734
1735 /* Look for possible opportunities to merge cases. */
1736 new_size = i = 1;
1737 while (i < old_size)
1738 {
1739 tree base_case, base_high;
1740 basic_block base_bb;
1741
1742 base_case = gimple_switch_label (stmt, i);
1743
1744 gcc_assert (base_case)((void)(!(base_case) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1744, __FUNCTION__), 0 : 0))
;
1745 base_bb = label_to_block (cfun(cfun + 0), CASE_LABEL (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1745, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1745, __FUNCTION__)))))
);
1746
1747 /* Discard cases that have the same destination as the default case or
1748 whose destination blocks have already been removed as unreachable. */
1749 if (base_bb == NULLnullptr
1750 || base_bb == default_bb
1751 || (removed_labels
1752 && removed_labels->contains (CASE_LABEL (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1752, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1752, __FUNCTION__)))))
)))
1753 {
1754 i++;
1755 continue;
1756 }
1757
1758 base_high = CASE_HIGH (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1758, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1758, __FUNCTION__)))))
1759 ? CASE_HIGH (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1759, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1759, __FUNCTION__)))))
1760 : CASE_LOW (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1760, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1760, __FUNCTION__)))))
;
1761 next_index = i + 1;
1762
1763 /* Try to merge case labels. Break out when we reach the end
1764 of the label vector or when we cannot merge the next case
1765 label with the current one. */
1766 while (next_index < old_size)
1767 {
1768 tree merge_case = gimple_switch_label (stmt, next_index);
1769 basic_block merge_bb = label_to_block (cfun(cfun + 0), CASE_LABEL (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1769, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1769, __FUNCTION__)))))
);
1770 wide_int bhp1 = wi::to_wide (base_high) + 1;
1771
1772 /* Merge the cases if they jump to the same place,
1773 and their ranges are consecutive. */
1774 if (merge_bb == base_bb
1775 && (removed_labels == NULLnullptr
1776 || !removed_labels->contains (CASE_LABEL (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1776, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1776, __FUNCTION__)))))
))
1777 && wi::to_wide (CASE_LOW (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1777, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1777, __FUNCTION__)))))
) == bhp1)
1778 {
1779 base_high
1780 = (CASE_HIGH (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1780, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1780, __FUNCTION__)))))
1781 ? CASE_HIGH (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1781, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1781, __FUNCTION__)))))
: CASE_LOW (merge_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((merge_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1781, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1781, __FUNCTION__)))))
);
1782 CASE_HIGH (base_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((base_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1782, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1782, __FUNCTION__)))))
= base_high;
1783 next_index++;
1784 }
1785 else
1786 break;
1787 }
1788
1789 /* Discard cases that have an unreachable destination block. */
1790 if (EDGE_COUNT (base_bb->succs)vec_safe_length (base_bb->succs) == 0
1791 && gimple_seq_unreachable_p (bb_seq (base_bb))
1792 /* Don't optimize this if __builtin_unreachable () is the
1793 implicitly added one by the C++ FE too early, before
1794 -Wreturn-type can be diagnosed. We'll optimize it later
1795 during switchconv pass or any other cfg cleanup. */
1796 && (gimple_in_ssa_p (cfun(cfun + 0))
1797 || (LOCATION_LOCUS (gimple_location (last_stmt (base_bb)))((IS_ADHOC_LOC (gimple_location (last_stmt (base_bb)))) ? get_location_from_adhoc_loc
(line_table, gimple_location (last_stmt (base_bb))) : (gimple_location
(last_stmt (base_bb))))
1798 != BUILTINS_LOCATION((location_t) 1))))
1799 {
1800 edge base_edge = find_edge (gimple_bb (stmt), base_bb);
1801 if (base_edge != NULLnullptr)
1802 {
1803 for (gimple_stmt_iterator gsi = gsi_start_bb (base_bb);
1804 !gsi_end_p (gsi); gsi_next (&gsi))
1805 if (glabel *stmt = dyn_cast <glabel *> (gsi_stmt (gsi)))
1806 {
1807 if (FORCED_LABEL (gimple_label_label (stmt))((tree_check ((gimple_label_label (stmt)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1807, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
1808 || DECL_NONLOCAL (gimple_label_label (stmt))((contains_struct_check ((gimple_label_label (stmt)), (TS_DECL_COMMON
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1808, __FUNCTION__))->decl_common.nonlocal_flag)
)
1809 {
1810 /* Forced/non-local labels aren't going to be removed,
1811 but they will be moved to some neighbouring basic
1812 block. If some later case label refers to one of
1813 those labels, we should throw that case away rather
1814 than keeping it around and refering to some random
1815 other basic block without an edge to it. */
1816 if (removed_labels == NULLnullptr)
1817 removed_labels = new hash_set<tree>;
1818 removed_labels->add (gimple_label_label (stmt));
1819 }
1820 }
1821 else
1822 break;
1823 remove_edge_and_dominated_blocks (base_edge);
1824 }
1825 i = next_index;
1826 continue;
1827 }
1828
1829 if (new_size < i)
1830 gimple_switch_set_label (stmt, new_size,
1831 gimple_switch_label (stmt, i));
1832 i = next_index;
1833 new_size++;
1834 }
1835
1836 gcc_assert (new_size <= old_size)((void)(!(new_size <= old_size) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1836, __FUNCTION__), 0 : 0))
;
1837
1838 if (new_size < old_size)
1839 gimple_switch_set_num_labels (stmt, new_size);
1840
1841 delete removed_labels;
1842 return new_size < old_size;
1843}
1844
1845/* Look for blocks ending in a multiway branch (a GIMPLE_SWITCH),
1846 and scan the sorted vector of cases. Combine the ones jumping to the
1847 same label. */
1848
1849bool
1850group_case_labels (void)
1851{
1852 basic_block bb;
1853 bool changed = false;
1854
1855 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
1856 {
1857 gimple *stmt = last_stmt (bb);
1858 if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
1859 changed |= group_case_labels_stmt (as_a <gswitch *> (stmt));
1860 }
1861
1862 return changed;
1863}
1864
1865/* Checks whether we can merge block B into block A. */
1866
1867static bool
1868gimple_can_merge_blocks_p (basic_block a, basic_block b)
1869{
1870 gimple *stmt;
1871
1872 if (!single_succ_p (a))
1873 return false;
1874
1875 if (single_succ_edge (a)->flags & EDGE_COMPLEX(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE
)
)
1876 return false;
1877
1878 if (single_succ (a) != b)
1879 return false;
1880
1881 if (!single_pred_p (b))
1882 return false;
1883
1884 if (a == ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr)
1885 || b == EXIT_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_exit_block_ptr))
1886 return false;
1887
1888 /* If A ends by a statement causing exceptions or something similar, we
1889 cannot merge the blocks. */
1890 stmt = last_stmt (a);
1891 if (stmt && stmt_ends_bb_p (stmt))
1892 return false;
1893
1894 /* Do not allow a block with only a non-local label to be merged. */
1895 if (stmt)
1896 if (glabel *label_stmt = dyn_cast <glabel *> (stmt))
1897 if (DECL_NONLOCAL (gimple_label_label (label_stmt))((contains_struct_check ((gimple_label_label (label_stmt)), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1897, __FUNCTION__))->decl_common.nonlocal_flag)
)
1898 return false;
1899
1900 /* Examine the labels at the beginning of B. */
1901 for (gimple_stmt_iterator gsi = gsi_start_bb (b); !gsi_end_p (gsi);
1902 gsi_next (&gsi))
1903 {
1904 tree lab;
1905 glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
1906 if (!label_stmt)
1907 break;
1908 lab = gimple_label_label (label_stmt);
1909
1910 /* Do not remove user forced labels or for -O0 any user labels. */
1911 if (!DECL_ARTIFICIAL (lab)((contains_struct_check ((lab), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1911, __FUNCTION__))->decl_common.artificial_flag)
&& (!optimizeglobal_options.x_optimize || FORCED_LABEL (lab)((tree_check ((lab), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1911, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
))
1912 return false;
1913 }
1914
1915 /* Protect simple loop latches. We only want to avoid merging
1916 the latch with the loop header or with a block in another
1917 loop in this case. */
1918 if (current_loops((cfun + 0)->x_current_loops)
1919 && b->loop_father->latch == b
1920 && loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES)
1921 && (b->loop_father->header == a
1922 || b->loop_father != a->loop_father))
1923 return false;
1924
1925 /* It must be possible to eliminate all phi nodes in B. If ssa form
1926 is not up-to-date and a name-mapping is registered, we cannot eliminate
1927 any phis. Symbols marked for renaming are never a problem though. */
1928 for (gphi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi);
1929 gsi_next (&gsi))
1930 {
1931 gphi *phi = gsi.phi ();
1932 /* Technically only new names matter. */
1933 if (name_registered_for_update_p (PHI_RESULT (phi)get_def_from_ptr (gimple_phi_result_ptr (phi))))
1934 return false;
1935 }
1936
1937 /* When not optimizing, don't merge if we'd lose goto_locus. */
1938 if (!optimizeglobal_options.x_optimize
1939 && single_succ_edge (a)->goto_locus != UNKNOWN_LOCATION((location_t) 0))
1940 {
1941 location_t goto_locus = single_succ_edge (a)->goto_locus;
1942 gimple_stmt_iterator prev, next;
1943 prev = gsi_last_nondebug_bb (a);
1944 next = gsi_after_labels (b);
1945 if (!gsi_end_p (next) && is_gimple_debug (gsi_stmt (next)))
1946 gsi_next_nondebug (&next);
1947 if ((gsi_end_p (prev)
1948 || gimple_location (gsi_stmt (prev)) != goto_locus)
1949 && (gsi_end_p (next)
1950 || gimple_location (gsi_stmt (next)) != goto_locus))
1951 return false;
1952 }
1953
1954 return true;
1955}
1956
1957/* Replaces all uses of NAME by VAL. */
1958
1959void
1960replace_uses_by (tree name, tree val)
1961{
1962 imm_use_iterator imm_iter;
1963 use_operand_p use;
1964 gimple *stmt;
1965 edge e;
1966
1967 FOR_EACH_IMM_USE_STMT (stmt, imm_iter, name)for (struct auto_end_imm_use_stmt_traverse auto_end_imm_use_stmt_traverse
((((stmt) = first_imm_use_stmt (&(imm_iter), (name))), &
(imm_iter))); !end_imm_use_stmt_p (&(imm_iter)); (void) (
(stmt) = next_imm_use_stmt (&(imm_iter))))
1968 {
1969 /* Mark the block if we change the last stmt in it. */
1970 if (cfgcleanup_altered_bbs
1971 && stmt_ends_bb_p (stmt))
1972 bitmap_set_bit (cfgcleanup_altered_bbs, gimple_bb (stmt)->index);
1973
1974 FOR_EACH_IMM_USE_ON_STMT (use, imm_iter)for ((use) = first_imm_use_on_stmt (&(imm_iter)); !end_imm_use_on_stmt_p
(&(imm_iter)); (void) ((use) = next_imm_use_on_stmt (&
(imm_iter))))
1975 {
1976 replace_exp (use, val);
1977
1978 if (gimple_code (stmt) == GIMPLE_PHI)
1979 {
1980 e = gimple_phi_arg_edge (as_a <gphi *> (stmt),
1981 PHI_ARG_INDEX_FROM_USE (use)phi_arg_index_from_use (use));
1982 if (e->flags & EDGE_ABNORMAL
1983 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (val)(tree_check ((val), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1983, __FUNCTION__, (SSA_NAME)))->base.asm_written_flag
)
1984 {
1985 /* This can only occur for virtual operands, since
1986 for the real ones SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name))
1987 would prevent replacement. */
1988 gcc_checking_assert (virtual_operand_p (name))((void)(!(virtual_operand_p (name)) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1988, __FUNCTION__), 0 : 0))
;
1989 SSA_NAME_OCCURS_IN_ABNORMAL_PHI (val)(tree_check ((val), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 1989, __FUNCTION__, (SSA_NAME)))->base.asm_written_flag
= 1;
1990 }
1991 }
1992 }
1993
1994 if (gimple_code (stmt) != GIMPLE_PHI)
1995 {
1996 gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
1997 gimple *orig_stmt = stmt;
1998 size_t i;
1999
2000 /* FIXME. It shouldn't be required to keep TREE_CONSTANT
2001 on ADDR_EXPRs up-to-date on GIMPLE. Propagation will
2002 only change sth from non-invariant to invariant, and only
2003 when propagating constants. */
2004 if (is_gimple_min_invariant (val))
2005 for (i = 0; i < gimple_num_ops (stmt); i++)
2006 {
2007 tree op = gimple_op (stmt, i);
2008 /* Operands may be empty here. For example, the labels
2009 of a GIMPLE_COND are nulled out following the creation
2010 of the corresponding CFG edges. */
2011 if (op && TREE_CODE (op)((enum tree_code) (op)->base.code) == ADDR_EXPR)
2012 recompute_tree_invariant_for_addr_expr (op);
2013 }
2014
2015 if (fold_stmt (&gsi))
2016 stmt = gsi_stmt (gsi);
2017
2018 if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt))
2019 gimple_purge_dead_eh_edges (gimple_bb (stmt));
2020
2021 update_stmt (stmt);
2022 }
2023 }
2024
2025 gcc_checking_assert (has_zero_uses (name))((void)(!(has_zero_uses (name)) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2025, __FUNCTION__), 0 : 0))
;
2026
2027 /* Also update the trees stored in loop structures. */
2028 if (current_loops((cfun + 0)->x_current_loops))
2029 {
2030 for (auto loop : loops_list (cfun(cfun + 0), 0))
2031 substitute_in_loop_info (loop, name, val);
2032 }
2033}
2034
2035/* Merge block B into block A. */
2036
2037static void
2038gimple_merge_blocks (basic_block a, basic_block b)
2039{
2040 gimple_stmt_iterator last, gsi;
2041 gphi_iterator psi;
2042
2043 if (dump_file)
2044 fprintf (dump_file, "Merging blocks %d and %d\n", a->index, b->index);
2045
2046 /* Remove all single-valued PHI nodes from block B of the form
2047 V_i = PHI <V_j> by propagating V_j to all the uses of V_i. */
2048 gsi = gsi_last_bb (a);
2049 for (psi = gsi_start_phis (b); !gsi_end_p (psi); )
2050 {
2051 gimple *phi = gsi_stmt (psi);
2052 tree def = gimple_phi_result (phi), use = gimple_phi_arg_def (phi, 0);
2053 gimple *copy;
2054 bool may_replace_uses = (virtual_operand_p (def)
2055 || may_propagate_copy (def, use));
2056
2057 /* In case we maintain loop closed ssa form, do not propagate arguments
2058 of loop exit phi nodes. */
2059 if (current_loops((cfun + 0)->x_current_loops)
2060 && loops_state_satisfies_p (LOOP_CLOSED_SSA)
2061 && !virtual_operand_p (def)
2062 && TREE_CODE (use)((enum tree_code) (use)->base.code) == SSA_NAME
2063 && a->loop_father != b->loop_father)
2064 may_replace_uses = false;
2065
2066 if (!may_replace_uses)
2067 {
2068 gcc_assert (!virtual_operand_p (def))((void)(!(!virtual_operand_p (def)) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2068, __FUNCTION__), 0 : 0))
;
2069
2070 /* Note that just emitting the copies is fine -- there is no problem
2071 with ordering of phi nodes. This is because A is the single
2072 predecessor of B, therefore results of the phi nodes cannot
2073 appear as arguments of the phi nodes. */
2074 copy = gimple_build_assign (def, use);
2075 gsi_insert_after (&gsi, copy, GSI_NEW_STMT);
2076 remove_phi_node (&psi, false);
2077 }
2078 else
2079 {
2080 /* If we deal with a PHI for virtual operands, we can simply
2081 propagate these without fussing with folding or updating
2082 the stmt. */
2083 if (virtual_operand_p (def))
2084 {
2085 imm_use_iterator iter;
2086 use_operand_p use_p;
2087 gimple *stmt;
2088
2089 FOR_EACH_IMM_USE_STMT (stmt, iter, def)for (struct auto_end_imm_use_stmt_traverse auto_end_imm_use_stmt_traverse
((((stmt) = first_imm_use_stmt (&(iter), (def))), &(
iter))); !end_imm_use_stmt_p (&(iter)); (void) ((stmt) = next_imm_use_stmt
(&(iter))))
2090 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)for ((use_p) = first_imm_use_on_stmt (&(iter)); !end_imm_use_on_stmt_p
(&(iter)); (void) ((use_p) = next_imm_use_on_stmt (&
(iter))))
2091 SET_USE (use_p, use)set_ssa_use_from_ptr (use_p, use);
2092
2093 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (def)(tree_check ((def), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2093, __FUNCTION__, (SSA_NAME)))->base.asm_written_flag
)
2094 SSA_NAME_OCCURS_IN_ABNORMAL_PHI (use)(tree_check ((use), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2094, __FUNCTION__, (SSA_NAME)))->base.asm_written_flag
= 1;
2095 }
2096 else
2097 replace_uses_by (def, use);
2098
2099 remove_phi_node (&psi, true);
2100 }
2101 }
2102
2103 /* Ensure that B follows A. */
2104 move_block_after (b, a);
2105
2106 gcc_assert (single_succ_edge (a)->flags & EDGE_FALLTHRU)((void)(!(single_succ_edge (a)->flags & EDGE_FALLTHRU)
? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2106, __FUNCTION__), 0 : 0))
;
2107 gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)))((void)(!(!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a))) ?
fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2107, __FUNCTION__), 0 : 0))
;
2108
2109 /* Remove labels from B and set gimple_bb to A for other statements. */
2110 for (gsi = gsi_start_bb (b); !gsi_end_p (gsi);)
2111 {
2112 gimple *stmt = gsi_stmt (gsi);
2113 if (glabel *label_stmt = dyn_cast <glabel *> (stmt))
2114 {
2115 tree label = gimple_label_label (label_stmt);
2116 int lp_nr;
2117
2118 gsi_remove (&gsi, false);
2119
2120 /* Now that we can thread computed gotos, we might have
2121 a situation where we have a forced label in block B
2122 However, the label at the start of block B might still be
2123 used in other ways (think about the runtime checking for
2124 Fortran assigned gotos). So we cannot just delete the
2125 label. Instead we move the label to the start of block A. */
2126 if (FORCED_LABEL (label)((tree_check ((label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2126, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
)
2127 {
2128 gimple_stmt_iterator dest_gsi = gsi_start_bb (a);
2129 tree first_label = NULL_TREE(tree) nullptr;
2130 if (!gsi_end_p (dest_gsi))
2131 if (glabel *first_label_stmt
2132 = dyn_cast <glabel *> (gsi_stmt (dest_gsi)))
2133 first_label = gimple_label_label (first_label_stmt);
2134 if (first_label
2135 && (DECL_NONLOCAL (first_label)((contains_struct_check ((first_label), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2135, __FUNCTION__))->decl_common.nonlocal_flag)
2136 || EH_LANDING_PAD_NR (first_label)((tree_check ((first_label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2136, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
)
!= 0))
2137 gsi_insert_after (&dest_gsi, stmt, GSI_NEW_STMT);
2138 else
2139 gsi_insert_before (&dest_gsi, stmt, GSI_NEW_STMT);
2140 }
2141 /* Other user labels keep around in a form of a debug stmt. */
2142 else if (!DECL_ARTIFICIAL (label)((contains_struct_check ((label), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2142, __FUNCTION__))->decl_common.artificial_flag)
&& MAY_HAVE_DEBUG_BIND_STMTSglobal_options.x_flag_var_tracking_assignments)
2143 {
2144 gimple *dbg = gimple_build_debug_bind (label,
2145 integer_zero_nodeglobal_trees[TI_INTEGER_ZERO],
2146 stmt);
2147 gimple_debug_bind_reset_value (dbg);
2148 gsi_insert_before (&gsi, dbg, GSI_SAME_STMT);
2149 }
2150
2151 lp_nr = EH_LANDING_PAD_NR (label)((tree_check ((label), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2151, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
)
;
2152 if (lp_nr)
2153 {
2154 eh_landing_pad lp = get_eh_landing_pad_from_number (lp_nr);
2155 lp->post_landing_pad = NULLnullptr;
2156 }
2157 }
2158 else
2159 {
2160 gimple_set_bb (stmt, a);
2161 gsi_next (&gsi);
2162 }
2163 }
2164
2165 /* When merging two BBs, if their counts are different, the larger count
2166 is selected as the new bb count. This is to handle inconsistent
2167 profiles. */
2168 if (a->loop_father == b->loop_father)
2169 {
2170 a->count = a->count.merge (b->count);
2171 }
2172
2173 /* Merge the sequences. */
2174 last = gsi_last_bb (a);
2175 gsi_insert_seq_after (&last, bb_seq (b), GSI_NEW_STMT);
2176 set_bb_seq (b, NULLnullptr);
2177
2178 if (cfgcleanup_altered_bbs)
2179 bitmap_set_bit (cfgcleanup_altered_bbs, a->index);
2180}
2181
2182
2183/* Return the one of two successors of BB that is not reachable by a
2184 complex edge, if there is one. Else, return BB. We use
2185 this in optimizations that use post-dominators for their heuristics,
2186 to catch the cases in C++ where function calls are involved. */
2187
2188basic_block
2189single_noncomplex_succ (basic_block bb)
2190{
2191 edge e0, e1;
2192 if (EDGE_COUNT (bb->succs)vec_safe_length (bb->succs) != 2)
2193 return bb;
2194
2195 e0 = EDGE_SUCC (bb, 0)(*(bb)->succs)[(0)];
2196 e1 = EDGE_SUCC (bb, 1)(*(bb)->succs)[(1)];
2197 if (e0->flags & EDGE_COMPLEX(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE
)
)
2198 return e1->dest;
2199 if (e1->flags & EDGE_COMPLEX(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE
)
)
2200 return e0->dest;
2201
2202 return bb;
2203}
2204
2205/* T is CALL_EXPR. Set current_function_calls_* flags. */
2206
2207void
2208notice_special_calls (gcall *call)
2209{
2210 int flags = gimple_call_flags (call);
2211
2212 if (flags & ECF_MAY_BE_ALLOCA(1 << 5))
2213 cfun(cfun + 0)->calls_alloca = true;
2214 if (flags & ECF_RETURNS_TWICE(1 << 7))
2215 cfun(cfun + 0)->calls_setjmp = true;
2216}
2217
2218
2219/* Clear flags set by notice_special_calls. Used by dead code removal
2220 to update the flags. */
2221
2222void
2223clear_special_calls (void)
2224{
2225 cfun(cfun + 0)->calls_alloca = false;
2226 cfun(cfun + 0)->calls_setjmp = false;
2227}
2228
2229/* Remove PHI nodes associated with basic block BB and all edges out of BB. */
2230
2231static void
2232remove_phi_nodes_and_edges_for_unreachable_block (basic_block bb)
2233{
2234 /* Since this block is no longer reachable, we can just delete all
2235 of its PHI nodes. */
2236 remove_phi_nodes (bb);
2237
2238 /* Remove edges to BB's successors. */
2239 while (EDGE_COUNT (bb->succs)vec_safe_length (bb->succs) > 0)
2240 remove_edge (EDGE_SUCC (bb, 0)(*(bb)->succs)[(0)]);
2241}
2242
2243
2244/* Remove statements of basic block BB. */
2245
2246static void
2247remove_bb (basic_block bb)
2248{
2249 gimple_stmt_iterator i;
2250
2251 if (dump_file)
2252 {
2253 fprintf (dump_file, "Removing basic block %d\n", bb->index);
2254 if (dump_flags & TDF_DETAILS)
2255 {
2256 dump_bb (dump_file, bb, 0, TDF_BLOCKS);
2257 fprintf (dump_file, "\n");
2258 }
2259 }
2260
2261 if (current_loops((cfun + 0)->x_current_loops))
2262 {
2263 class loop *loop = bb->loop_father;
2264
2265 /* If a loop gets removed, clean up the information associated
2266 with it. */
2267 if (loop->latch == bb
2268 || loop->header == bb)
2269 free_numbers_of_iterations_estimates (loop);
2270 }
2271
2272 /* Remove all the instructions in the block. */
2273 if (bb_seq (bb) != NULLnullptr)
2274 {
2275 /* Walk backwards so as to get a chance to substitute all
2276 released DEFs into debug stmts. See
2277 eliminate_unnecessary_stmts() in tree-ssa-dce.c for more
2278 details. */
2279 for (i = gsi_last_bb (bb); !gsi_end_p (i);)
2280 {
2281 gimple *stmt = gsi_stmt (i);
2282 glabel *label_stmt = dyn_cast <glabel *> (stmt);
2283 if (label_stmt
2284 && (FORCED_LABEL (gimple_label_label (label_stmt))((tree_check ((gimple_label_label (label_stmt)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2284, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
2285 || DECL_NONLOCAL (gimple_label_label (label_stmt))((contains_struct_check ((gimple_label_label (label_stmt)), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2285, __FUNCTION__))->decl_common.nonlocal_flag)
))
2286 {
2287 basic_block new_bb;
2288 gimple_stmt_iterator new_gsi;
2289
2290 /* A non-reachable non-local label may still be referenced.
2291 But it no longer needs to carry the extra semantics of
2292 non-locality. */
2293 if (DECL_NONLOCAL (gimple_label_label (label_stmt))((contains_struct_check ((gimple_label_label (label_stmt)), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2293, __FUNCTION__))->decl_common.nonlocal_flag)
)
2294 {
2295 DECL_NONLOCAL (gimple_label_label (label_stmt))((contains_struct_check ((gimple_label_label (label_stmt)), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2295, __FUNCTION__))->decl_common.nonlocal_flag)
= 0;
2296 FORCED_LABEL (gimple_label_label (label_stmt))((tree_check ((gimple_label_label (label_stmt)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2296, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
= 1;
2297 }
2298
2299 new_bb = bb->prev_bb;
2300 /* Don't move any labels into ENTRY block. */
2301 if (new_bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr))
2302 {
2303 new_bb = single_succ (new_bb);
2304 gcc_assert (new_bb != bb)((void)(!(new_bb != bb) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2304, __FUNCTION__), 0 : 0))
;
2305 }
2306 if ((unsigned) bb->index < bb_to_omp_idx.length ()
2307 && ((unsigned) new_bb->index >= bb_to_omp_idx.length ()
2308 || (bb_to_omp_idx[bb->index]
2309 != bb_to_omp_idx[new_bb->index])))
2310 {
2311 /* During cfg pass make sure to put orphaned labels
2312 into the right OMP region. */
2313 unsigned int i;
2314 int idx;
2315 new_bb = NULLnullptr;
2316 FOR_EACH_VEC_ELT (bb_to_omp_idx, i, idx)for (i = 0; (bb_to_omp_idx).iterate ((i), &(idx)); ++(i))
2317 if (i >= NUM_FIXED_BLOCKS(2)
2318 && idx == bb_to_omp_idx[bb->index]
2319 && i != (unsigned) bb->index)
2320 {
2321 new_bb = BASIC_BLOCK_FOR_FN (cfun, i)((*(((cfun + 0))->cfg->x_basic_block_info))[(i)]);
2322 break;
2323 }
2324 if (new_bb == NULLnullptr)
2325 {
2326 new_bb = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr));
2327 gcc_assert (new_bb != bb)((void)(!(new_bb != bb) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2327, __FUNCTION__), 0 : 0))
;
2328 }
2329 }
2330 new_gsi = gsi_after_labels (new_bb);
2331 gsi_remove (&i, false);
2332 gsi_insert_before (&new_gsi, stmt, GSI_NEW_STMT);
2333 }
2334 else
2335 {
2336 /* Release SSA definitions. */
2337 release_defs (stmt);
2338 gsi_remove (&i, true);
2339 }
2340
2341 if (gsi_end_p (i))
2342 i = gsi_last_bb (bb);
2343 else
2344 gsi_prev (&i);
2345 }
2346 }
2347
2348 if ((unsigned) bb->index < bb_to_omp_idx.length ())
2349 bb_to_omp_idx[bb->index] = -1;
2350 remove_phi_nodes_and_edges_for_unreachable_block (bb);
2351 bb->il.gimple.seq = NULLnullptr;
2352 bb->il.gimple.phi_nodes = NULLnullptr;
2353}
2354
2355
2356/* Given a basic block BB and a value VAL for use in the final statement
2357 of the block (if a GIMPLE_COND, GIMPLE_SWITCH, or computed goto), return
2358 the edge that will be taken out of the block.
2359 If VAL is NULL_TREE, then the current value of the final statement's
2360 predicate or index is used.
2361 If the value does not match a unique edge, NULL is returned. */
2362
2363edge
2364find_taken_edge (basic_block bb, tree val)
2365{
2366 gimple *stmt;
2367
2368 stmt = last_stmt (bb);
2369
2370 /* Handle ENTRY and EXIT. */
2371 if (!stmt)
2372 return NULLnullptr;
2373
2374 if (gimple_code (stmt) == GIMPLE_COND)
2375 return find_taken_edge_cond_expr (as_a <gcond *> (stmt), val);
2376
2377 if (gimple_code (stmt) == GIMPLE_SWITCH)
2378 return find_taken_edge_switch_expr (as_a <gswitch *> (stmt), val);
2379
2380 if (computed_goto_p (stmt))
2381 {
2382 /* Only optimize if the argument is a label, if the argument is
2383 not a label then we cannot construct a proper CFG.
2384
2385 It may be the case that we only need to allow the LABEL_REF to
2386 appear inside an ADDR_EXPR, but we also allow the LABEL_REF to
2387 appear inside a LABEL_EXPR just to be safe. */
2388 if (val
2389 && (TREE_CODE (val)((enum tree_code) (val)->base.code) == ADDR_EXPR || TREE_CODE (val)((enum tree_code) (val)->base.code) == LABEL_EXPR)
2390 && TREE_CODE (TREE_OPERAND (val, 0))((enum tree_code) ((*((const_cast<tree*> (tree_operand_check
((val), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2390, __FUNCTION__))))))->base.code)
== LABEL_DECL)
2391 return find_taken_edge_computed_goto (bb, TREE_OPERAND (val, 0)(*((const_cast<tree*> (tree_operand_check ((val), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2391, __FUNCTION__)))))
);
2392 }
2393
2394 /* Otherwise we only know the taken successor edge if it's unique. */
2395 return single_succ_p (bb) ? single_succ_edge (bb) : NULLnullptr;
2396}
2397
2398/* Given a constant value VAL and the entry block BB to a GOTO_EXPR
2399 statement, determine which of the outgoing edges will be taken out of the
2400 block. Return NULL if either edge may be taken. */
2401
2402static edge
2403find_taken_edge_computed_goto (basic_block bb, tree val)
2404{
2405 basic_block dest;
2406 edge e = NULLnullptr;
2407
2408 dest = label_to_block (cfun(cfun + 0), val);
2409 if (dest)
2410 e = find_edge (bb, dest);
2411
2412 /* It's possible for find_edge to return NULL here on invalid code
2413 that abuses the labels-as-values extension (e.g. code that attempts to
2414 jump *between* functions via stored labels-as-values; PR 84136).
2415 If so, then we simply return that NULL for the edge.
2416 We don't currently have a way of detecting such invalid code, so we
2417 can't assert that it was the case when a NULL edge occurs here. */
2418
2419 return e;
2420}
2421
2422/* Given COND_STMT and a constant value VAL for use as the predicate,
2423 determine which of the two edges will be taken out of
2424 the statement's block. Return NULL if either edge may be taken.
2425 If VAL is NULL_TREE, then the current value of COND_STMT's predicate
2426 is used. */
2427
2428static edge
2429find_taken_edge_cond_expr (const gcond *cond_stmt, tree val)
2430{
2431 edge true_edge, false_edge;
2432
2433 if (val == NULL_TREE(tree) nullptr)
2434 {
2435 /* Use the current value of the predicate. */
2436 if (gimple_cond_true_p (cond_stmt))
2437 val = integer_one_nodeglobal_trees[TI_INTEGER_ONE];
2438 else if (gimple_cond_false_p (cond_stmt))
2439 val = integer_zero_nodeglobal_trees[TI_INTEGER_ZERO];
2440 else
2441 return NULLnullptr;
2442 }
2443 else if (TREE_CODE (val)((enum tree_code) (val)->base.code) != INTEGER_CST)
2444 return NULLnullptr;
2445
2446 extract_true_false_edges_from_block (gimple_bb (cond_stmt),
2447 &true_edge, &false_edge);
2448
2449 return (integer_zerop (val) ? false_edge : true_edge);
2450}
2451
2452/* Given SWITCH_STMT and an INTEGER_CST VAL for use as the index, determine
2453 which edge will be taken out of the statement's block. Return NULL if any
2454 edge may be taken.
2455 If VAL is NULL_TREE, then the current value of SWITCH_STMT's index
2456 is used. */
2457
2458edge
2459find_taken_edge_switch_expr (const gswitch *switch_stmt, tree val)
2460{
2461 basic_block dest_bb;
2462 edge e;
2463 tree taken_case;
2464
2465 if (gimple_switch_num_labels (switch_stmt) == 1)
2466 taken_case = gimple_switch_default_label (switch_stmt);
2467 else
2468 {
2469 if (val == NULL_TREE(tree) nullptr)
2470 val = gimple_switch_index (switch_stmt);
2471 if (TREE_CODE (val)((enum tree_code) (val)->base.code) != INTEGER_CST)
2472 return NULLnullptr;
2473 else
2474 taken_case = find_case_label_for_value (switch_stmt, val);
2475 }
2476 dest_bb = label_to_block (cfun(cfun + 0), CASE_LABEL (taken_case)(*((const_cast<tree*> (tree_operand_check (((tree_check
((taken_case), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2476, __FUNCTION__, (CASE_LABEL_EXPR)))), (2), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2476, __FUNCTION__)))))
);
2477
2478 e = find_edge (gimple_bb (switch_stmt), dest_bb);
2479 gcc_assert (e)((void)(!(e) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2479, __FUNCTION__), 0 : 0))
;
2480 return e;
2481}
2482
2483
2484/* Return the CASE_LABEL_EXPR that SWITCH_STMT will take for VAL.
2485 We can make optimal use here of the fact that the case labels are
2486 sorted: We can do a binary search for a case matching VAL. */
2487
2488tree
2489find_case_label_for_value (const gswitch *switch_stmt, tree val)
2490{
2491 size_t low, high, n = gimple_switch_num_labels (switch_stmt);
2492 tree default_case = gimple_switch_default_label (switch_stmt);
2493
2494 for (low = 0, high = n; high - low > 1; )
2495 {
2496 size_t i = (high + low) / 2;
2497 tree t = gimple_switch_label (switch_stmt, i);
2498 int cmp;
2499
2500 /* Cache the result of comparing CASE_LOW and val. */
2501 cmp = tree_int_cst_compare (CASE_LOW (t)(*((const_cast<tree*> (tree_operand_check (((tree_check
((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2501, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2501, __FUNCTION__)))))
, val);
2502
2503 if (cmp > 0)
2504 high = i;
2505 else
2506 low = i;
2507
2508 if (CASE_HIGH (t)(*((const_cast<tree*> (tree_operand_check (((tree_check
((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2508, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2508, __FUNCTION__)))))
== NULLnullptr)
2509 {
2510 /* A singe-valued case label. */
2511 if (cmp == 0)
2512 return t;
2513 }
2514 else
2515 {
2516 /* A case range. We can only handle integer ranges. */
2517 if (cmp <= 0 && tree_int_cst_compare (CASE_HIGH (t)(*((const_cast<tree*> (tree_operand_check (((tree_check
((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2517, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2517, __FUNCTION__)))))
, val) >= 0)
2518 return t;
2519 }
2520 }
2521
2522 return default_case;
2523}
2524
2525
2526/* Dump a basic block on stderr. */
2527
2528void
2529gimple_debug_bb (basic_block bb)
2530{
2531 dump_bb (stderrstderr, bb, 0, TDF_VOPS|TDF_MEMSYMS|TDF_BLOCKS);
2532}
2533
2534
2535/* Dump basic block with index N on stderr. */
2536
2537basic_block
2538gimple_debug_bb_n (int n)
2539{
2540 gimple_debug_bb (BASIC_BLOCK_FOR_FN (cfun, n)((*(((cfun + 0))->cfg->x_basic_block_info))[(n)]));
2541 return BASIC_BLOCK_FOR_FN (cfun, n)((*(((cfun + 0))->cfg->x_basic_block_info))[(n)]);
2542}
2543
2544
2545/* Dump the CFG on stderr.
2546
2547 FLAGS are the same used by the tree dumping functions
2548 (see TDF_* in dumpfile.h). */
2549
2550void
2551gimple_debug_cfg (dump_flags_t flags)
2552{
2553 gimple_dump_cfg (stderrstderr, flags);
2554}
2555
2556
2557/* Dump the program showing basic block boundaries on the given FILE.
2558
2559 FLAGS are the same used by the tree dumping functions (see TDF_* in
2560 tree.h). */
2561
2562void
2563gimple_dump_cfg (FILE *file, dump_flags_t flags)
2564{
2565 if (flags & TDF_DETAILS)
2566 {
2567 dump_function_header (file, current_function_decl, flags);
2568 fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n",
2569 n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks), n_edges_for_fn (cfun)(((cfun + 0))->cfg->x_n_edges),
2570 last_basic_block_for_fn (cfun)(((cfun + 0))->cfg->x_last_basic_block));
2571
2572 brief_dump_cfg (file, flags);
2573 fprintf (file, "\n");
2574 }
2575
2576 if (flags & TDF_STATS)
2577 dump_cfg_stats (file);
2578
2579 dump_function_to_file (current_function_decl, file, flags | TDF_BLOCKS);
2580}
2581
2582
2583/* Dump CFG statistics on FILE. */
2584
2585void
2586dump_cfg_stats (FILE *file)
2587{
2588 static long max_num_merged_labels = 0;
2589 unsigned long size, total = 0;
2590 long num_edges;
2591 basic_block bb;
2592 const char * const fmt_str = "%-30s%-13s%12s\n";
2593 const char * const fmt_str_1 = "%-30s%13d" PRsa (11)"%" "11" "l" "u" "%c" "\n";
2594 const char * const fmt_str_2 = "%-30s%13ld" PRsa (11)"%" "11" "l" "u" "%c" "\n";
2595 const char * const fmt_str_3 = "%-43s" PRsa (11)"%" "11" "l" "u" "%c" "\n";
2596 const char *funcname = current_function_name ();
2597
2598 fprintf (file, "\nCFG Statistics for %s\n\n", funcname);
2599
2600 fprintf (file, "---------------------------------------------------------\n");
2601 fprintf (file, fmt_str, "", " Number of ", "Memory");
2602 fprintf (file, fmt_str, "", " instances ", "used ");
2603 fprintf (file, "---------------------------------------------------------\n");
2604
2605 size = n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks) * sizeof (struct basic_block_def);
2606 total += size;
2607 fprintf (file, fmt_str_1, "Basic blocks", n_basic_blocks_for_fn (cfun)(((cfun + 0))->cfg->x_n_basic_blocks),
2608 SIZE_AMOUNT (size)(uint64_t)(((size) < 10 * 1024 ? (size) : ((size) < 10 *
(1024 * 1024) ? (size) / 1024 : (size) / (1024 * 1024)))), (
(size) < 10 * 1024 ? ' ' : ((size) < 10 * (1024 * 1024)
? 'k' : 'M'))
);
2609
2610 num_edges = 0;
2611 FOR_EACH_BB_FN (bb, cfun)for (bb = ((cfun + 0))->cfg->x_entry_block_ptr->next_bb
; bb != ((cfun + 0))->cfg->x_exit_block_ptr; bb = bb->
next_bb)
2612 num_edges += EDGE_COUNT (bb->succs)vec_safe_length (bb->succs);
2613 size = num_edges * sizeof (class edge_def);
2614 total += size;
2615 fprintf (file, fmt_str_2, "Edges", num_edges, SIZE_AMOUNT (size)(uint64_t)(((size) < 10 * 1024 ? (size) : ((size) < 10 *
(1024 * 1024) ? (size) / 1024 : (size) / (1024 * 1024)))), (
(size) < 10 * 1024 ? ' ' : ((size) < 10 * (1024 * 1024)
? 'k' : 'M'))
);
2616
2617 fprintf (file, "---------------------------------------------------------\n");
2618 fprintf (file, fmt_str_3, "Total memory used by CFG data",
2619 SIZE_AMOUNT (total)(uint64_t)(((total) < 10 * 1024 ? (total) : ((total) < 10
* (1024 * 1024) ? (total) / 1024 : (total) / (1024 * 1024)))
), ((total) < 10 * 1024 ? ' ' : ((total) < 10 * (1024 *
1024) ? 'k' : 'M'))
);
2620 fprintf (file, "---------------------------------------------------------\n");
2621 fprintf (file, "\n");
2622
2623 if (cfg_stats.num_merged_labels > max_num_merged_labels)
2624 max_num_merged_labels = cfg_stats.num_merged_labels;
2625
2626 fprintf (file, "Coalesced label blocks: %ld (Max so far: %ld)\n",
2627 cfg_stats.num_merged_labels, max_num_merged_labels);
2628
2629 fprintf (file, "\n");
2630}
2631
2632
2633/* Dump CFG statistics on stderr. Keep extern so that it's always
2634 linked in the final executable. */
2635
2636DEBUG_FUNCTION__attribute__ ((__used__)) void
2637debug_cfg_stats (void)
2638{
2639 dump_cfg_stats (stderrstderr);
2640}
2641
2642/*---------------------------------------------------------------------------
2643 Miscellaneous helpers
2644---------------------------------------------------------------------------*/
2645
2646/* Return true if T, a GIMPLE_CALL, can make an abnormal transfer of control
2647 flow. Transfers of control flow associated with EH are excluded. */
2648
2649static bool
2650call_can_make_abnormal_goto (gimple *t)
2651{
2652 /* If the function has no non-local labels, then a call cannot make an
2653 abnormal transfer of control. */
2654 if (!cfun(cfun + 0)->has_nonlocal_label
2655 && !cfun(cfun + 0)->calls_setjmp)
2656 return false;
2657
2658 /* Likewise if the call has no side effects. */
2659 if (!gimple_has_side_effects (t))
2660 return false;
2661
2662 /* Likewise if the called function is leaf. */
2663 if (gimple_call_flags (t) & ECF_LEAF(1 << 10))
2664 return false;
2665
2666 return true;
2667}
2668
2669
2670/* Return true if T can make an abnormal transfer of control flow.
2671 Transfers of control flow associated with EH are excluded. */
2672
2673bool
2674stmt_can_make_abnormal_goto (gimple *t)
2675{
2676 if (computed_goto_p (t))
2677 return true;
2678 if (is_gimple_call (t))
2679 return call_can_make_abnormal_goto (t);
2680 return false;
2681}
2682
2683
2684/* Return true if T represents a stmt that always transfers control. */
2685
2686bool
2687is_ctrl_stmt (gimple *t)
2688{
2689 switch (gimple_code (t))
2690 {
2691 case GIMPLE_COND:
2692 case GIMPLE_SWITCH:
2693 case GIMPLE_GOTO:
2694 case GIMPLE_RETURN:
2695 case GIMPLE_RESX:
2696 return true;
2697 default:
2698 return false;
2699 }
2700}
2701
2702
2703/* Return true if T is a statement that may alter the flow of control
2704 (e.g., a call to a non-returning function). */
2705
2706bool
2707is_ctrl_altering_stmt (gimple *t)
2708{
2709 gcc_assert (t)((void)(!(t) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2709, __FUNCTION__), 0 : 0))
;
2710
2711 switch (gimple_code (t))
2712 {
2713 case GIMPLE_CALL:
2714 /* Per stmt call flag indicates whether the call could alter
2715 controlflow. */
2716 if (gimple_call_ctrl_altering_p (t))
2717 return true;
2718 break;
2719
2720 case GIMPLE_EH_DISPATCH:
2721 /* EH_DISPATCH branches to the individual catch handlers at
2722 this level of a try or allowed-exceptions region. It can
2723 fallthru to the next statement as well. */
2724 return true;
2725
2726 case GIMPLE_ASM:
2727 if (gimple_asm_nlabels (as_a <gasm *> (t)) > 0)
2728 return true;
2729 break;
2730
2731 CASE_GIMPLE_OMPcase GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: case GIMPLE_OMP_FOR
: case GIMPLE_OMP_SECTIONS: case GIMPLE_OMP_SECTIONS_SWITCH: case
GIMPLE_OMP_SINGLE: case GIMPLE_OMP_TARGET: case GIMPLE_OMP_TEAMS
: case GIMPLE_OMP_SCOPE: case GIMPLE_OMP_SECTION: case GIMPLE_OMP_MASTER
: case GIMPLE_OMP_MASKED: case GIMPLE_OMP_TASKGROUP: case GIMPLE_OMP_ORDERED
: case GIMPLE_OMP_CRITICAL: case GIMPLE_OMP_SCAN: case GIMPLE_OMP_RETURN
: case GIMPLE_OMP_ATOMIC_LOAD: case GIMPLE_OMP_ATOMIC_STORE: case
GIMPLE_OMP_CONTINUE
:
2732 /* OpenMP directives alter control flow. */
2733 return true;
2734
2735 case GIMPLE_TRANSACTION:
2736 /* A transaction start alters control flow. */
2737 return true;
2738
2739 default:
2740 break;
2741 }
2742
2743 /* If a statement can throw, it alters control flow. */
2744 return stmt_can_throw_internal (cfun(cfun + 0), t);
2745}
2746
2747
2748/* Return true if T is a simple local goto. */
2749
2750bool
2751simple_goto_p (gimple *t)
2752{
2753 return (gimple_code (t) == GIMPLE_GOTO
2754 && TREE_CODE (gimple_goto_dest (t))((enum tree_code) (gimple_goto_dest (t))->base.code) == LABEL_DECL);
2755}
2756
2757
2758/* Return true if STMT should start a new basic block. PREV_STMT is
2759 the statement preceding STMT. It is used when STMT is a label or a
2760 case label. Labels should only start a new basic block if their
2761 previous statement wasn't a label. Otherwise, sequence of labels
2762 would generate unnecessary basic blocks that only contain a single
2763 label. */
2764
2765static inline bool
2766stmt_starts_bb_p (gimple *stmt, gimple *prev_stmt)
2767{
2768 if (stmt == NULLnullptr)
2769 return false;
2770
2771 /* PREV_STMT is only set to a debug stmt if the debug stmt is before
2772 any nondebug stmts in the block. We don't want to start another
2773 block in this case: the debug stmt will already have started the
2774 one STMT would start if we weren't outputting debug stmts. */
2775 if (prev_stmt && is_gimple_debug (prev_stmt))
2776 return false;
2777
2778 /* Labels start a new basic block only if the preceding statement
2779 wasn't a label of the same type. This prevents the creation of
2780 consecutive blocks that have nothing but a single label. */
2781 if (glabel *label_stmt = dyn_cast <glabel *> (stmt))
2782 {
2783 /* Nonlocal and computed GOTO targets always start a new block. */
2784 if (DECL_NONLOCAL (gimple_label_label (label_stmt))((contains_struct_check ((gimple_label_label (label_stmt)), (
TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2784, __FUNCTION__))->decl_common.nonlocal_flag)
2785 || FORCED_LABEL (gimple_label_label (label_stmt))((tree_check ((gimple_label_label (label_stmt)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2785, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
)
2786 return true;
2787
2788 if (glabel *plabel = safe_dyn_cast <glabel *> (prev_stmt))
2789 {
2790 if (DECL_NONLOCAL (gimple_label_label (plabel))((contains_struct_check ((gimple_label_label (plabel)), (TS_DECL_COMMON
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2790, __FUNCTION__))->decl_common.nonlocal_flag)
2791 || !DECL_ARTIFICIAL (gimple_label_label (plabel))((contains_struct_check ((gimple_label_label (plabel)), (TS_DECL_COMMON
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2791, __FUNCTION__))->decl_common.artificial_flag)
)
2792 return true;
2793
2794 cfg_stats.num_merged_labels++;
2795 return false;
2796 }
2797 else
2798 return true;
2799 }
2800 else if (gimple_code (stmt) == GIMPLE_CALL)
2801 {
2802 if (gimple_call_flags (stmt) & ECF_RETURNS_TWICE(1 << 7))
2803 /* setjmp acts similar to a nonlocal GOTO target and thus should
2804 start a new block. */
2805 return true;
2806 if (gimple_call_internal_p (stmt, IFN_PHI)
2807 && prev_stmt
2808 && gimple_code (prev_stmt) != GIMPLE_LABEL
2809 && (gimple_code (prev_stmt) != GIMPLE_CALL
2810 || ! gimple_call_internal_p (prev_stmt, IFN_PHI)))
2811 /* PHI nodes start a new block unless preceeded by a label
2812 or another PHI. */
2813 return true;
2814 }
2815
2816 return false;
2817}
2818
2819
2820/* Return true if T should end a basic block. */
2821
2822bool
2823stmt_ends_bb_p (gimple *t)
2824{
2825 return is_ctrl_stmt (t) || is_ctrl_altering_stmt (t);
2826}
2827
2828/* Remove block annotations and other data structures. */
2829
2830void
2831delete_tree_cfg_annotations (struct function *fn)
2832{
2833 vec_free (label_to_block_map_for_fn (fn)((fn)->cfg->x_label_to_block_map));
2834}
2835
2836/* Return the virtual phi in BB. */
2837
2838gphi *
2839get_virtual_phi (basic_block bb)
2840{
2841 for (gphi_iterator gsi = gsi_start_phis (bb);
2842 !gsi_end_p (gsi);
2843 gsi_next (&gsi))
2844 {
2845 gphi *phi = gsi.phi ();
2846
2847 if (virtual_operand_p (PHI_RESULT (phi)get_def_from_ptr (gimple_phi_result_ptr (phi))))
2848 return phi;
2849 }
2850
2851 return NULLnullptr;
2852}
2853
2854/* Return the first statement in basic block BB. */
2855
2856gimple *
2857first_stmt (basic_block bb)
2858{
2859 gimple_stmt_iterator i = gsi_start_bb (bb);
2860 gimple *stmt = NULLnullptr;
2861
2862 while (!gsi_end_p (i) && is_gimple_debug ((stmt = gsi_stmt (i))))
2863 {
2864 gsi_next (&i);
2865 stmt = NULLnullptr;
2866 }
2867 return stmt;
2868}
2869
2870/* Return the first non-label statement in basic block BB. */
2871
2872static gimple *
2873first_non_label_stmt (basic_block bb)
2874{
2875 gimple_stmt_iterator i = gsi_start_bb (bb);
2876 while (!gsi_end_p (i) && gimple_code (gsi_stmt (i)) == GIMPLE_LABEL)
2877 gsi_next (&i);
2878 return !gsi_end_p (i) ? gsi_stmt (i) : NULLnullptr;
2879}
2880
2881/* Return the last statement in basic block BB. */
2882
2883gimple *
2884last_stmt (basic_block bb)
2885{
2886 gimple_stmt_iterator i = gsi_last_bb (bb);
2887 gimple *stmt = NULLnullptr;
2888
2889 while (!gsi_end_p (i) && is_gimple_debug ((stmt = gsi_stmt (i))))
2890 {
2891 gsi_prev (&i);
2892 stmt = NULLnullptr;
2893 }
2894 return stmt;
2895}
2896
2897/* Return the last statement of an otherwise empty block. Return NULL
2898 if the block is totally empty, or if it contains more than one
2899 statement. */
2900
2901gimple *
2902last_and_only_stmt (basic_block bb)
2903{
2904 gimple_stmt_iterator i = gsi_last_nondebug_bb (bb);
2905 gimple *last, *prev;
2906
2907 if (gsi_end_p (i))
2908 return NULLnullptr;
2909
2910 last = gsi_stmt (i);
2911 gsi_prev_nondebug (&i);
2912 if (gsi_end_p (i))
2913 return last;
2914
2915 /* Empty statements should no longer appear in the instruction stream.
2916 Everything that might have appeared before should be deleted by
2917 remove_useless_stmts, and the optimizers should just gsi_remove
2918 instead of smashing with build_empty_stmt.
2919
2920 Thus the only thing that should appear here in a block containing
2921 one executable statement is a label. */
2922 prev = gsi_stmt (i);
2923 if (gimple_code (prev) == GIMPLE_LABEL)
2924 return last;
2925 else
2926 return NULLnullptr;
2927}
2928
2929/* Returns the basic block after which the new basic block created
2930 by splitting edge EDGE_IN should be placed. Tries to keep the new block
2931 near its "logical" location. This is of most help to humans looking
2932 at debugging dumps. */
2933
2934basic_block
2935split_edge_bb_loc (edge edge_in)
2936{
2937 basic_block dest = edge_in->dest;
2938 basic_block dest_prev = dest->prev_bb;
2939
2940 if (dest_prev)
2941 {
2942 edge e = find_edge (dest_prev, dest);
2943 if (e && !(e->flags & EDGE_COMPLEX(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE
)
))
2944 return edge_in->src;
2945 }
2946 return dest_prev;
2947}
2948
2949/* Split a (typically critical) edge EDGE_IN. Return the new block.
2950 Abort on abnormal edges. */
2951
2952static basic_block
2953gimple_split_edge (edge edge_in)
2954{
2955 basic_block new_bb, after_bb, dest;
2956 edge new_edge, e;
2957
2958 /* Abnormal edges cannot be split. */
2959 gcc_assert (!(edge_in->flags & EDGE_ABNORMAL))((void)(!(!(edge_in->flags & EDGE_ABNORMAL)) ? fancy_abort
("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2959, __FUNCTION__), 0 : 0))
;
2960
2961 dest = edge_in->dest;
2962
2963 after_bb = split_edge_bb_loc (edge_in);
2964
2965 new_bb = create_empty_bb (after_bb);
2966 new_bb->count = edge_in->count ();
2967
2968 /* We want to avoid re-allocating PHIs when we first
2969 add the fallthru edge from new_bb to dest but we also
2970 want to avoid changing PHI argument order when
2971 first redirecting edge_in away from dest. The former
2972 avoids changing PHI argument order by adding them
2973 last and then the redirection swapping it back into
2974 place by means of unordered remove.
2975 So hack around things by temporarily removing all PHIs
2976 from the destination during the edge redirection and then
2977 making sure the edges stay in order. */
2978 gimple_seq saved_phis = phi_nodes (dest);
2979 unsigned old_dest_idx = edge_in->dest_idx;
2980 set_phi_nodes (dest, NULLnullptr);
2981 new_edge = make_single_succ_edge (new_bb, dest, EDGE_FALLTHRU);
2982 e = redirect_edge_and_branch (edge_in, new_bb);
2983 gcc_assert (e == edge_in && new_edge->dest_idx == old_dest_idx)((void)(!(e == edge_in && new_edge->dest_idx == old_dest_idx
) ? fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 2983, __FUNCTION__), 0 : 0))
;
2984 /* set_phi_nodes sets the BB of the PHI nodes, so do it manually here. */
2985 dest->il.gimple.phi_nodes = saved_phis;
2986
2987 return new_bb;
2988}
2989
2990
2991/* Verify properties of the address expression T whose base should be
2992 TREE_ADDRESSABLE if VERIFY_ADDRESSABLE is true. */
2993
2994static bool
2995verify_address (tree t, bool verify_addressable)
2996{
2997 bool old_constant;
2998 bool old_side_effects;
2999 bool new_constant;
3000 bool new_side_effects;
3001
3002 old_constant = TREE_CONSTANT (t)((non_type_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3002, __FUNCTION__))->base.constant_flag)
;
3003 old_side_effects = TREE_SIDE_EFFECTS (t)((non_type_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3003, __FUNCTION__))->base.side_effects_flag)
;
3004
3005 recompute_tree_invariant_for_addr_expr (t);
3006 new_side_effects = TREE_SIDE_EFFECTS (t)((non_type_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3006, __FUNCTION__))->base.side_effects_flag)
;
3007 new_constant = TREE_CONSTANT (t)((non_type_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3007, __FUNCTION__))->base.constant_flag)
;
3008
3009 if (old_constant != new_constant)
3010 {
3011 error ("constant not recomputed when %<ADDR_EXPR%> changed");
3012 return true;
3013 }
3014 if (old_side_effects != new_side_effects)
3015 {
3016 error ("side effects not recomputed when %<ADDR_EXPR%> changed");
3017 return true;
3018 }
3019
3020 tree base = TREE_OPERAND (t, 0)(*((const_cast<tree*> (tree_operand_check ((t), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3020, __FUNCTION__)))))
;
3021 while (handled_component_p (base))
3022 base = TREE_OPERAND (base, 0)(*((const_cast<tree*> (tree_operand_check ((base), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3022, __FUNCTION__)))))
;
3023
3024 if (!(VAR_P (base)(((enum tree_code) (base)->base.code) == VAR_DECL)
3025 || TREE_CODE (base)((enum tree_code) (base)->base.code) == PARM_DECL
3026 || TREE_CODE (base)((enum tree_code) (base)->base.code) == RESULT_DECL))
3027 return false;
3028
3029 if (verify_addressable && !TREE_ADDRESSABLE (base)((base)->base.addressable_flag))
3030 {
3031 error ("address taken but %<TREE_ADDRESSABLE%> bit not set");
3032 return true;
3033 }
3034
3035 return false;
3036}
3037
3038
3039/* Verify if EXPR is a valid GIMPLE reference expression. If
3040 REQUIRE_LVALUE is true verifies it is an lvalue. Returns true
3041 if there is an error, otherwise false. */
3042
3043static bool
3044verify_types_in_gimple_reference (tree expr, bool require_lvalue)
3045{
3046 const char *code_name = get_tree_code_name (TREE_CODE (expr)((enum tree_code) (expr)->base.code));
3047
3048 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == REALPART_EXPR
3049 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == IMAGPART_EXPR
3050 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == BIT_FIELD_REF)
3051 {
3052 tree op = TREE_OPERAND (expr, 0)(*((const_cast<tree*> (tree_operand_check ((expr), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3052, __FUNCTION__)))))
;
3053 if (!is_gimple_reg_type (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3053, __FUNCTION__))->typed.type)
))
3054 {
3055 error ("non-scalar %qs", code_name);
3056 return true;
3057 }
3058
3059 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == BIT_FIELD_REF)
3060 {
3061 tree t1 = TREE_OPERAND (expr, 1)(*((const_cast<tree*> (tree_operand_check ((expr), (1),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3061, __FUNCTION__)))))
;
3062 tree t2 = TREE_OPERAND (expr, 2)(*((const_cast<tree*> (tree_operand_check ((expr), (2),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3062, __FUNCTION__)))))
;
3063 poly_uint64 size, bitpos;
3064 if (!poly_int_tree_p (t1, &size)
3065 || !poly_int_tree_p (t2, &bitpos)
3066 || !types_compatible_p (bitsizetypesizetype_tab[(int) stk_bitsizetype], TREE_TYPE (t1)((contains_struct_check ((t1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3066, __FUNCTION__))->typed.type)
)
3067 || !types_compatible_p (bitsizetypesizetype_tab[(int) stk_bitsizetype], TREE_TYPE (t2)((contains_struct_check ((t2), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3067, __FUNCTION__))->typed.type)
))
3068 {
3069 error ("invalid position or size operand to %qs", code_name);
3070 return true;
3071 }
3072 if (INTEGRAL_TYPE_P (TREE_TYPE (expr))(((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3072, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3072, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3072, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3073 && maybe_ne (TYPE_PRECISION (TREE_TYPE (expr))((tree_class_check ((((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3073, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3073, __FUNCTION__))->type_common.precision)
, size))
3074 {
3075 error ("integral result type precision does not match "
3076 "field size of %qs", code_name);
3077 return true;
3078 }
3079 else if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))(((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3079, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3079, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3079, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3080 && TYPE_MODE (TREE_TYPE (expr))((((enum tree_code) ((tree_class_check ((((contains_struct_check
((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3080, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3080, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3080, __FUNCTION__))->typed.type)) : (((contains_struct_check
((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3080, __FUNCTION__))->typed.type))->type_common.mode)
!= BLKmode((void) 0, E_BLKmode)
3081 && maybe_ne (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr))((((enum tree_code) ((tree_class_check ((((contains_struct_check
((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3081, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3081, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3081, __FUNCTION__))->typed.type)) : (((contains_struct_check
((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3081, __FUNCTION__))->typed.type))->type_common.mode)
),
3082 size))
3083 {
3084 error ("mode size of non-integral result does not "
3085 "match field size of %qs",
3086 code_name);
3087 return true;
3088 }
3089 if (INTEGRAL_TYPE_P (TREE_TYPE (op))(((enum tree_code) (((contains_struct_check ((op), (TS_TYPED)
, "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3089, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3089, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3089, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3090 && !type_has_mode_precision_p (TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3090, __FUNCTION__))->typed.type)
))
3091 {
3092 error ("%qs of non-mode-precision operand", code_name);
3093 return true;
3094 }
3095 if (!AGGREGATE_TYPE_P (TREE_TYPE (op))(((enum tree_code) (((contains_struct_check ((op), (TS_TYPED)
, "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3095, __FUNCTION__))->typed.type))->base.code) == ARRAY_TYPE
|| (((enum tree_code) (((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3095, __FUNCTION__))->typed.type))->base.code) == RECORD_TYPE
|| ((enum tree_code) (((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3095, __FUNCTION__))->typed.type))->base.code) == UNION_TYPE
|| ((enum tree_code) (((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3095, __FUNCTION__))->typed.type))->base.code) == QUAL_UNION_TYPE
))
3096 && maybe_gt (size + bitpos,maybe_lt (tree_to_poly_uint64 (((tree_class_check ((((contains_struct_check
((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3097, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3097, __FUNCTION__))->type_common.size)), size + bitpos)
3097 tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (op))))maybe_lt (tree_to_poly_uint64 (((tree_class_check ((((contains_struct_check
((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3097, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3097, __FUNCTION__))->type_common.size)), size + bitpos)
)
3098 {
3099 error ("position plus size exceeds size of referenced object in "
3100 "%qs", code_name);
3101 return true;
3102 }
3103 }
3104
3105 if ((TREE_CODE (expr)((enum tree_code) (expr)->base.code) == REALPART_EXPR
3106 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == IMAGPART_EXPR)
3107 && !useless_type_conversion_p (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3107, __FUNCTION__))->typed.type)
,
3108 TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3108, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3108, __FUNCTION__))->typed.type)
))
3109 {
3110 error ("type mismatch in %qs reference", code_name);
3111 debug_generic_stmt (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3111, __FUNCTION__))->typed.type)
);
3112 debug_generic_stmt (TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3112, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3112, __FUNCTION__))->typed.type)
);
3113 return true;
3114 }
3115 expr = op;
3116 }
3117
3118 while (handled_component_p (expr))
3119 {
3120 code_name = get_tree_code_name (TREE_CODE (expr)((enum tree_code) (expr)->base.code));
3121
3122 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == REALPART_EXPR
3123 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == IMAGPART_EXPR
3124 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == BIT_FIELD_REF)
3125 {
3126 error ("non-top-level %qs", code_name);
3127 return true;
3128 }
3129
3130 tree op = TREE_OPERAND (expr, 0)(*((const_cast<tree*> (tree_operand_check ((expr), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3130, __FUNCTION__)))))
;
3131
3132 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == ARRAY_REF
3133 || TREE_CODE (expr)((enum tree_code) (expr)->base.code) == ARRAY_RANGE_REF)
3134 {
3135 if (!is_gimple_val (TREE_OPERAND (expr, 1)(*((const_cast<tree*> (tree_operand_check ((expr), (1),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3135, __FUNCTION__)))))
)
3136 || (TREE_OPERAND (expr, 2)(*((const_cast<tree*> (tree_operand_check ((expr), (2),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3136, __FUNCTION__)))))
3137 && !is_gimple_val (TREE_OPERAND (expr, 2)(*((const_cast<tree*> (tree_operand_check ((expr), (2),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3137, __FUNCTION__)))))
))
3138 || (TREE_OPERAND (expr, 3)(*((const_cast<tree*> (tree_operand_check ((expr), (3),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3138, __FUNCTION__)))))
3139 && !is_gimple_val (TREE_OPERAND (expr, 3)(*((const_cast<tree*> (tree_operand_check ((expr), (3),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3139, __FUNCTION__)))))
)))
3140 {
3141 error ("invalid operands to %qs", code_name);
3142 debug_generic_stmt (expr);
3143 return true;
3144 }
3145 }
3146
3147 /* Verify if the reference array element types are compatible. */
3148 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == ARRAY_REF
3149 && !useless_type_conversion_p (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3149, __FUNCTION__))->typed.type)
,
3150 TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3150, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3150, __FUNCTION__))->typed.type)
))
3151 {
3152 error ("type mismatch in %qs", code_name);
3153 debug_generic_stmt (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3153, __FUNCTION__))->typed.type)
);
3154 debug_generic_stmt (TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3154, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3154, __FUNCTION__))->typed.type)
);
3155 return true;
3156 }
3157 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == ARRAY_RANGE_REF
3158 && !useless_type_conversion_p (TREE_TYPE (TREE_TYPE (expr))((contains_struct_check ((((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3158, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3158, __FUNCTION__))->typed.type)
,
3159 TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3159, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3159, __FUNCTION__))->typed.type)
))
3160 {
3161 error ("type mismatch in %qs", code_name);
3162 debug_generic_stmt (TREE_TYPE (TREE_TYPE (expr))((contains_struct_check ((((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3162, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3162, __FUNCTION__))->typed.type)
);
3163 debug_generic_stmt (TREE_TYPE (TREE_TYPE (op))((contains_struct_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3163, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3163, __FUNCTION__))->typed.type)
);
3164 return true;
3165 }
3166
3167 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == COMPONENT_REF)
3168 {
3169 if (TREE_OPERAND (expr, 2)(*((const_cast<tree*> (tree_operand_check ((expr), (2),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3169, __FUNCTION__)))))
3170 && !is_gimple_val (TREE_OPERAND (expr, 2)(*((const_cast<tree*> (tree_operand_check ((expr), (2),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3170, __FUNCTION__)))))
))
3171 {
3172 error ("invalid %qs offset operator", code_name);
3173 return true;
3174 }
3175 if (!useless_type_conversion_p (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3175, __FUNCTION__))->typed.type)
,
3176 TREE_TYPE (TREE_OPERAND (expr, 1))((contains_struct_check (((*((const_cast<tree*> (tree_operand_check
((expr), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3176, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3176, __FUNCTION__))->typed.type)
))
3177 {
3178 error ("type mismatch in %qs", code_name);
3179 debug_generic_stmt (TREE_TYPE (expr)((contains_struct_check ((expr), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3179, __FUNCTION__))->typed.type)
);
3180 debug_generic_stmt (TREE_TYPE (TREE_OPERAND (expr, 1))((contains_struct_check (((*((const_cast<tree*> (tree_operand_check
((expr), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3180, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3180, __FUNCTION__))->typed.type)
);
3181 return true;
3182 }
3183 }
3184
3185 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == VIEW_CONVERT_EXPR)
3186 {
3187 /* For VIEW_CONVERT_EXPRs which are allowed here too, we only check
3188 that their operand is not an SSA name or an invariant when
3189 requiring an lvalue (this usually means there is a SRA or IPA-SRA
3190 bug). Otherwise there is nothing to verify, gross mismatches at
3191 most invoke undefined behavior. */
3192 if (require_lvalue
3193 && (TREE_CODE (op)((enum tree_code) (op)->base.code) == SSA_NAME
3194 || is_gimple_min_invariant (op)))
3195 {
3196 error ("conversion of %qs on the left hand side of %qs",
3197 get_tree_code_name (TREE_CODE (op)((enum tree_code) (op)->base.code)), code_name);
3198 debug_generic_stmt (expr);
3199 return true;
3200 }
3201 else if (TREE_CODE (op)((enum tree_code) (op)->base.code) == SSA_NAME
3202 && TYPE_SIZE (TREE_TYPE (expr))((tree_class_check ((((contains_struct_check ((expr), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3202, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3202, __FUNCTION__))->type_common.size)
!= TYPE_SIZE (TREE_TYPE (op))((tree_class_check ((((contains_struct_check ((op), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3202, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3202, __FUNCTION__))->type_common.size)
)
3203 {
3204 error ("conversion of register to a different size in %qs",
3205 code_name);
3206 debug_generic_stmt (expr);
3207 return true;
3208 }
3209 else if (!handled_component_p (op))
3210 return false;
3211 }
3212
3213 expr = op;
3214 }
3215
3216 code_name = get_tree_code_name (TREE_CODE (expr)((enum tree_code) (expr)->base.code));
3217
3218 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == MEM_REF)
3219 {
3220 if (!is_gimple_mem_ref_addr (TREE_OPERAND (expr, 0)(*((const_cast<tree*> (tree_operand_check ((expr), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3220, __FUNCTION__)))))
)
3221 || (TREE_CODE (TREE_OPERAND (expr, 0))((enum tree_code) ((*((const_cast<tree*> (tree_operand_check
((expr), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3221, __FUNCTION__))))))->base.code)
== ADDR_EXPR
3222 && verify_address (TREE_OPERAND (expr, 0)(*((const_cast<tree*> (tree_operand_check ((expr), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3222, __FUNCTION__)))))
, false)))
3223 {
3224 error ("invalid address operand in %qs", code_name);
3225 debug_generic_stmt (expr);
3226 return true;
3227 }
3228 if (!poly_int_tree_p (TREE_OPERAND (expr, 1)(*((const_cast<tree*> (tree_operand_check ((expr), (1),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3228, __FUNCTION__)))))
)
3229 || !POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 1)))(((enum tree_code) (((contains_struct_check (((*((const_cast<
tree*> (tree_operand_check ((expr), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3229, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3229, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check (((*((const_cast
<tree*> (tree_operand_check ((expr), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3229, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3229, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
)
3230 {
3231 error ("invalid offset operand in %qs", code_name);
3232 debug_generic_stmt (expr);
3233 return true;
3234 }
3235 if (MR_DEPENDENCE_CLIQUE (expr)((tree_check2 ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3235, __FUNCTION__, (MEM_REF), (TARGET_MEM_REF)))->base.
u.dependence_info.clique)
!= 0
3236 && MR_DEPENDENCE_CLIQUE (expr)((tree_check2 ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3236, __FUNCTION__, (MEM_REF), (TARGET_MEM_REF)))->base.
u.dependence_info.clique)
> cfun(cfun + 0)->last_clique)
3237 {
3238 error ("invalid clique in %qs", code_name);
3239 debug_generic_stmt (expr);
3240 return true;
3241 }
3242 }
3243 else if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == TARGET_MEM_REF)
3244 {
3245 if (!TMR_BASE (expr)((*((const_cast<tree*> (tree_operand_check (((tree_check
((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3245, __FUNCTION__, (TARGET_MEM_REF)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3245, __FUNCTION__))))))
3246 || !is_gimple_mem_ref_addr (TMR_BASE (expr)((*((const_cast<tree*> (tree_operand_check (((tree_check
((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3246, __FUNCTION__, (TARGET_MEM_REF)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3246, __FUNCTION__))))))
)
3247 || (TREE_CODE (TMR_BASE (expr))((enum tree_code) (((*((const_cast<tree*> (tree_operand_check
(((tree_check ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3247, __FUNCTION__, (TARGET_MEM_REF)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3247, __FUNCTION__)))))))->base.code)
== ADDR_EXPR
3248 && verify_address (TMR_BASE (expr)((*((const_cast<tree*> (tree_operand_check (((tree_check
((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3248, __FUNCTION__, (TARGET_MEM_REF)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3248, __FUNCTION__))))))
, false)))
3249 {
3250 error ("invalid address operand in %qs", code_name);
3251 return true;
3252 }
3253 if (!TMR_OFFSET (expr)((*((const_cast<tree*> (tree_operand_check (((tree_check
((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3253, __FUNCTION__, (TARGET_MEM_REF)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3253, __FUNCTION__))))))
3254 || !poly_int_tree_p (TMR_OFFSET (expr)((*((const_cast<tree*> (tree_operand_check (((tree_check
((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3254, __FUNCTION__, (TARGET_MEM_REF)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3254, __FUNCTION__))))))
)
3255 || !POINTER_TYPE_P (TREE_TYPE (TMR_OFFSET (expr)))(((enum tree_code) (((contains_struct_check ((((*((const_cast
<tree*> (tree_operand_check (((tree_check ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__, (TARGET_MEM_REF)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__))))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check ((((*((const_cast
<tree*> (tree_operand_check (((tree_check ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__, (TARGET_MEM_REF)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__))))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3255, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
)
3256 {
3257 error ("invalid offset operand in %qs", code_name);
3258 debug_generic_stmt (expr);
3259 return true;
3260 }
3261 if (MR_DEPENDENCE_CLIQUE (expr)((tree_check2 ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3261, __FUNCTION__, (MEM_REF), (TARGET_MEM_REF)))->base.
u.dependence_info.clique)
!= 0
3262 && MR_DEPENDENCE_CLIQUE (expr)((tree_check2 ((expr), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3262, __FUNCTION__, (MEM_REF), (TARGET_MEM_REF)))->base.
u.dependence_info.clique)
> cfun(cfun + 0)->last_clique)
3263 {
3264 error ("invalid clique in %qs", code_name);
3265 debug_generic_stmt (expr);
3266 return true;
3267 }
3268 }
3269 else if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == INDIRECT_REF)
3270 {
3271 error ("%qs in gimple IL", code_name);
3272 debug_generic_stmt (expr);
3273 return true;
3274 }
3275
3276 if (!require_lvalue
3277 && (TREE_CODE (expr)((enum tree_code) (expr)->base.code) == SSA_NAME || is_gimple_min_invariant (expr)))
3278 return false;
3279
3280 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) != SSA_NAME && is_gimple_id (expr))
3281 return false;
3282
3283 if (TREE_CODE (expr)((enum tree_code) (expr)->base.code) != TARGET_MEM_REF
3284 && TREE_CODE (expr)((enum tree_code) (expr)->base.code) != MEM_REF)
3285 {
3286 error ("invalid expression for min lvalue");
3287 return true;
3288 }
3289
3290 return false;
3291}
3292
3293/* Returns true if there is one pointer type in TYPE_POINTER_TO (SRC_OBJ)
3294 list of pointer-to types that is trivially convertible to DEST. */
3295
3296static bool
3297one_pointer_to_useless_type_conversion_p (tree dest, tree src_obj)
3298{
3299 tree src;
3300
3301 if (!TYPE_POINTER_TO (src_obj)((tree_class_check ((src_obj), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3301, __FUNCTION__))->type_common.pointer_to)
)
3302 return true;
3303
3304 for (src = TYPE_POINTER_TO (src_obj)((tree_class_check ((src_obj), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3304, __FUNCTION__))->type_common.pointer_to)
; src; src = TYPE_NEXT_PTR_TO (src)((tree_check ((src), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3304, __FUNCTION__, (POINTER_TYPE)))->type_non_common.minval
)
)
3305 if (useless_type_conversion_p (dest, src))
3306 return true;
3307
3308 return false;
3309}
3310
3311/* Return true if TYPE1 is a fixed-point type and if conversions to and
3312 from TYPE2 can be handled by FIXED_CONVERT_EXPR. */
3313
3314static bool
3315valid_fixed_convert_types_p (tree type1, tree type2)
3316{
3317 return (FIXED_POINT_TYPE_P (type1)(((enum tree_code) (type1)->base.code) == FIXED_POINT_TYPE
)
3318 && (INTEGRAL_TYPE_P (type2)(((enum tree_code) (type2)->base.code) == ENUMERAL_TYPE ||
((enum tree_code) (type2)->base.code) == BOOLEAN_TYPE || (
(enum tree_code) (type2)->base.code) == INTEGER_TYPE)
3319 || SCALAR_FLOAT_TYPE_P (type2)(((enum tree_code) (type2)->base.code) == REAL_TYPE)
3320 || FIXED_POINT_TYPE_P (type2)(((enum tree_code) (type2)->base.code) == FIXED_POINT_TYPE
)
));
3321}
3322
3323/* Verify the contents of a GIMPLE_CALL STMT. Returns true when there
3324 is a problem, otherwise false. */
3325
3326static bool
3327verify_gimple_call (gcall *stmt)
3328{
3329 tree fn = gimple_call_fn (stmt);
3330 tree fntype, fndecl;
3331 unsigned i;
3332
3333 if (gimple_call_internal_p (stmt))
3334 {
3335 if (fn)
3336 {
3337 error ("gimple call has two targets");
3338 debug_generic_stmt (fn);
3339 return true;
3340 }
3341 }
3342 else
3343 {
3344 if (!fn)
3345 {
3346 error ("gimple call has no target");
3347 return true;
3348 }
3349 }
3350
3351 if (fn && !is_gimple_call_addr (fn))
3352 {
3353 error ("invalid function in gimple call");
3354 debug_generic_stmt (fn);
3355 return true;
3356 }
3357
3358 if (fn
3359 && (!POINTER_TYPE_P (TREE_TYPE (fn))(((enum tree_code) (((contains_struct_check ((fn), (TS_TYPED)
, "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3359, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check ((fn), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3359, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
3360 || (TREE_CODE (TREE_TYPE (TREE_TYPE (fn)))((enum tree_code) (((contains_struct_check ((((contains_struct_check
((fn), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3360, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3360, __FUNCTION__))->typed.type))->base.code)
!= FUNCTION_TYPE
3361 && TREE_CODE (TREE_TYPE (TREE_TYPE (fn)))((enum tree_code) (((contains_struct_check ((((contains_struct_check
((fn), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3361, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3361, __FUNCTION__))->typed.type))->base.code)
!= METHOD_TYPE)))
3362 {
3363 error ("non-function in gimple call");
3364 return true;
3365 }
3366
3367 fndecl = gimple_call_fndecl (stmt);
3368 if (fndecl
3369 && TREE_CODE (fndecl)((enum tree_code) (fndecl)->base.code) == FUNCTION_DECL
3370 && DECL_LOOPING_CONST_OR_PURE_P (fndecl)((tree_check ((fndecl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3370, __FUNCTION__, (FUNCTION_DECL)))->function_decl.looping_const_or_pure_flag
)
3371 && !DECL_PURE_P (fndecl)((tree_check ((fndecl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3371, __FUNCTION__, (FUNCTION_DECL)))->function_decl.pure_flag
)
3372 && !TREE_READONLY (fndecl)((non_type_check ((fndecl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3372, __FUNCTION__))->base.readonly_flag)
)
3373 {
3374 error ("invalid pure const state for function");
3375 return true;
3376 }
3377
3378 tree lhs = gimple_call_lhs (stmt);
3379 if (lhs
3380 && (!is_gimple_reg (lhs)
3381 && (!is_gimple_lvalue (lhs)
3382 || verify_types_in_gimple_reference
3383 (TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == WITH_SIZE_EXPR
3384 ? TREE_OPERAND (lhs, 0)(*((const_cast<tree*> (tree_operand_check ((lhs), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3384, __FUNCTION__)))))
: lhs, true))))
3385 {
3386 error ("invalid LHS in gimple call");
3387 return true;
3388 }
3389
3390 if (gimple_call_ctrl_altering_p (stmt)
3391 && gimple_call_noreturn_p (stmt)
3392 && should_remove_lhs_p (lhs))
3393 {
3394 error ("LHS in %<noreturn%> call");
3395 return true;
3396 }
3397
3398 fntype = gimple_call_fntype (stmt);
3399 if (fntype
3400 && lhs
3401 && !useless_type_conversion_p (TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3401, __FUNCTION__))->typed.type)
, TREE_TYPE (fntype)((contains_struct_check ((fntype), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3401, __FUNCTION__))->typed.type)
)
3402 /* ??? At least C++ misses conversions at assignments from
3403 void * call results.
3404 For now simply allow arbitrary pointer type conversions. */
3405 && !(POINTER_TYPE_P (TREE_TYPE (lhs))(((enum tree_code) (((contains_struct_check ((lhs), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3405, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3405, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
3406 && POINTER_TYPE_P (TREE_TYPE (fntype))(((enum tree_code) (((contains_struct_check ((fntype), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3406, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check ((fntype), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3406, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
))
3407 {
3408 error ("invalid conversion in gimple call");
3409 debug_generic_stmt (TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3409, __FUNCTION__))->typed.type)
);
3410 debug_generic_stmt (TREE_TYPE (fntype)((contains_struct_check ((fntype), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3410, __FUNCTION__))->typed.type)
);
3411 return true;
3412 }
3413
3414 if (gimple_call_chain (stmt)
3415 && !is_gimple_val (gimple_call_chain (stmt)))
3416 {
3417 error ("invalid static chain in gimple call");
3418 debug_generic_stmt (gimple_call_chain (stmt));
3419 return true;
3420 }
3421
3422 /* If there is a static chain argument, the call should either be
3423 indirect, or the decl should have DECL_STATIC_CHAIN set. */
3424 if (gimple_call_chain (stmt)
3425 && fndecl
3426 && !DECL_STATIC_CHAIN (fndecl)((tree_check ((fndecl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3426, __FUNCTION__, (FUNCTION_DECL)))->decl_with_vis.regdecl_flag
)
)
3427 {
3428 error ("static chain with function that doesn%'t use one");
3429 return true;
3430 }
3431
3432 if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
3433 {
3434 switch (DECL_FUNCTION_CODE (fndecl))
3435 {
3436 case BUILT_IN_UNREACHABLE:
3437 case BUILT_IN_TRAP:
3438 if (gimple_call_num_args (stmt) > 0)
3439 {
3440 /* Built-in unreachable with parameters might not be caught by
3441 undefined behavior sanitizer. Front-ends do check users do not
3442 call them that way but we also produce calls to
3443 __builtin_unreachable internally, for example when IPA figures
3444 out a call cannot happen in a legal program. In such cases,
3445 we must make sure arguments are stripped off. */
3446 error ("%<__builtin_unreachable%> or %<__builtin_trap%> call "
3447 "with arguments");
3448 return true;
3449 }
3450 break;
3451 default:
3452 break;
3453 }
3454 }
3455
3456 /* For a call to .DEFERRED_INIT,
3457 LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, IS_VLA)
3458 we should guarantee that the 1st and the 3rd arguments are consistent:
3459 1st argument: SIZE of the DECL;
3460 3rd argument: IS_VLA, 0 NO, 1 YES;
3461
3462 if IS_VLA is false, the 1st argument should be a constant and the same as
3463 the size of the LHS. */
3464 if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
3465 {
3466 tree size_of_arg0 = gimple_call_arg (stmt, 0);
3467 tree size_of_lhs = TYPE_SIZE_UNIT (TREE_TYPE (lhs))((tree_class_check ((((contains_struct_check ((lhs), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3467, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3467, __FUNCTION__))->type_common.size_unit)
;
3468 tree is_vla_node = gimple_call_arg (stmt, 2);
3469 bool is_vla = (bool) TREE_INT_CST_LOW (is_vla_node)((unsigned long) (*tree_int_cst_elt_check ((is_vla_node), (0)
, "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3469, __FUNCTION__)))
;
3470
3471 if (TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == SSA_NAME)
3472 lhs = SSA_NAME_VAR (lhs)((tree_check ((lhs), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3472, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((lhs)->ssa_name.var)->base
.code) == IDENTIFIER_NODE ? (tree) nullptr : (lhs)->ssa_name
.var)
;
3473
3474 poly_uint64 size_from_arg0, size_from_lhs;
3475 bool is_constant_size_arg0 = poly_int_tree_p (size_of_arg0,
3476 &size_from_arg0);
3477 bool is_constant_size_lhs = poly_int_tree_p (size_of_lhs,
3478 &size_from_lhs);
3479 if (!is_vla)
3480 {
3481 if (!is_constant_size_arg0)
3482 {
3483 error ("%<DEFFERED_INIT%> calls for non-VLA should have "
3484 "constant size for the first argument");
3485 return true;
3486 }
3487 else if (!is_constant_size_lhs)
3488 {
3489 error ("%<DEFFERED_INIT%> calls for non-VLA should have "
3490 "constant size for the LHS");
3491 return true;
3492 }
3493 else if (maybe_ne (size_from_arg0, size_from_lhs))
3494 {
3495 error ("%<DEFFERED_INIT%> calls for non-VLA should have same "
3496 "constant size for the first argument and LHS");
3497 return true;
3498 }
3499 }
3500 }
3501
3502 /* ??? The C frontend passes unpromoted arguments in case it
3503 didn't see a function declaration before the call. So for now
3504 leave the call arguments mostly unverified. Once we gimplify
3505 unit-at-a-time we have a chance to fix this. */
3506 for (i = 0; i < gimple_call_num_args (stmt); ++i)
3507 {
3508 tree arg = gimple_call_arg (stmt, i);
3509 if ((is_gimple_reg_type (TREE_TYPE (arg)((contains_struct_check ((arg), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3509, __FUNCTION__))->typed.type)
)
3510 && !is_gimple_val (arg))
3511 || (!is_gimple_reg_type (TREE_TYPE (arg)((contains_struct_check ((arg), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3511, __FUNCTION__))->typed.type)
)
3512 && !is_gimple_lvalue (arg)))
3513 {
3514 error ("invalid argument to gimple call");
3515 debug_generic_expr (arg);
3516 return true;
3517 }
3518 if (!is_gimple_reg (arg))
3519 {
3520 if (TREE_CODE (arg)((enum tree_code) (arg)->base.code) == WITH_SIZE_EXPR)
3521 arg = TREE_OPERAND (arg, 0)(*((const_cast<tree*> (tree_operand_check ((arg), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3521, __FUNCTION__)))))
;
3522 if (verify_types_in_gimple_reference (arg, false))
3523 return true;
3524 }
3525 }
3526
3527 return false;
3528}
3529
3530/* Verifies the gimple comparison with the result type TYPE and
3531 the operands OP0 and OP1, comparison code is CODE. */
3532
3533static bool
3534verify_gimple_comparison (tree type, tree op0, tree op1, enum tree_code code)
3535{
3536 tree op0_type = TREE_TYPE (op0)((contains_struct_check ((op0), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3536, __FUNCTION__))->typed.type)
;
3537 tree op1_type = TREE_TYPE (op1)((contains_struct_check ((op1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3537, __FUNCTION__))->typed.type)
;
3538
3539 if (!is_gimple_val (op0) || !is_gimple_val (op1))
3540 {
3541 error ("invalid operands in gimple comparison");
3542 return true;
3543 }
3544
3545 /* For comparisons we do not have the operations type as the
3546 effective type the comparison is carried out in. Instead
3547 we require that either the first operand is trivially
3548 convertible into the second, or the other way around. */
3549 if (!useless_type_conversion_p (op0_type, op1_type)
3550 && !useless_type_conversion_p (op1_type, op0_type))
3551 {
3552 error ("mismatching comparison operand types");
3553 debug_generic_expr (op0_type);
3554 debug_generic_expr (op1_type);
3555 return true;
3556 }
3557
3558 /* The resulting type of a comparison may be an effective boolean type. */
3559 if (INTEGRAL_TYPE_P (type)(((enum tree_code) (type)->base.code) == ENUMERAL_TYPE || (
(enum tree_code) (type)->base.code) == BOOLEAN_TYPE || ((enum
tree_code) (type)->base.code) == INTEGER_TYPE)
3560 && (TREE_CODE (type)((enum tree_code) (type)->base.code) == BOOLEAN_TYPE
3561 || TYPE_PRECISION (type)((tree_class_check ((type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3561, __FUNCTION__))->type_common.precision)
== 1))
3562 {
3563 if ((TREE_CODE (op0_type)((enum tree_code) (op0_type)->base.code) == VECTOR_TYPE
3564 || TREE_CODE (op1_type)((enum tree_code) (op1_type)->base.code) == VECTOR_TYPE)
3565 && code != EQ_EXPR && code != NE_EXPR
3566 && !VECTOR_BOOLEAN_TYPE_P (op0_type)(((enum tree_code) (op0_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((op0_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3566, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
3567 && !VECTOR_INTEGER_TYPE_P (op0_type)((((enum tree_code) (op0_type)->base.code) == VECTOR_TYPE)
&& ((enum tree_code) (((contains_struct_check ((op0_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3567, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
)
3568 {
3569 error ("unsupported operation or type for vector comparison"
3570 " returning a boolean");
3571 debug_generic_expr (op0_type);
3572 debug_generic_expr (op1_type);
3573 return true;
3574 }
3575 }
3576 /* Or a boolean vector type with the same element count
3577 as the comparison operand types. */
3578 else if (TREE_CODE (type)((enum tree_code) (type)->base.code) == VECTOR_TYPE
3579 && TREE_CODE (TREE_TYPE (type))((enum tree_code) (((contains_struct_check ((type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3579, __FUNCTION__))->typed.type))->base.code)
== BOOLEAN_TYPE)
3580 {
3581 if (TREE_CODE (op0_type)((enum tree_code) (op0_type)->base.code) != VECTOR_TYPE
3582 || TREE_CODE (op1_type)((enum tree_code) (op1_type)->base.code) != VECTOR_TYPE)
3583 {
3584 error ("non-vector operands in vector comparison");
3585 debug_generic_expr (op0_type);
3586 debug_generic_expr (op1_type);
3587 return true;
3588 }
3589
3590 if (maybe_ne (TYPE_VECTOR_SUBPARTS (type),
3591 TYPE_VECTOR_SUBPARTS (op0_type)))
3592 {
3593 error ("invalid vector comparison resulting type");
3594 debug_generic_expr (type);
3595 return true;
3596 }
3597 }
3598 else
3599 {
3600 error ("bogus comparison result type");
3601 debug_generic_expr (type);
3602 return true;
3603 }
3604
3605 return false;
3606}
3607
3608/* Verify a gimple assignment statement STMT with an unary rhs.
3609 Returns true if anything is wrong. */
3610
3611static bool
3612verify_gimple_assign_unary (gassign *stmt)
3613{
3614 enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
3615 tree lhs = gimple_assign_lhs (stmt);
3616 tree lhs_type = TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3616, __FUNCTION__))->typed.type)
;
3617 tree rhs1 = gimple_assign_rhs1 (stmt);
3618 tree rhs1_type = TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3618, __FUNCTION__))->typed.type)
;
3619
3620 if (!is_gimple_reg (lhs))
3621 {
3622 error ("non-register as LHS of unary operation");
3623 return true;
3624 }
3625
3626 if (!is_gimple_val (rhs1))
3627 {
3628 error ("invalid operand in unary operation");
3629 return true;
3630 }
3631
3632 const char* const code_name = get_tree_code_name (rhs_code);
3633
3634 /* First handle conversions. */
3635 switch (rhs_code)
3636 {
3637 CASE_CONVERTcase NOP_EXPR: case CONVERT_EXPR:
3638 {
3639 /* Allow conversions between vectors with the same number of elements,
3640 provided that the conversion is OK for the element types too. */
3641 if (VECTOR_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE)
3642 && VECTOR_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE)
3643 && known_eq (TYPE_VECTOR_SUBPARTS (lhs_type),(!maybe_ne (TYPE_VECTOR_SUBPARTS (lhs_type), TYPE_VECTOR_SUBPARTS
(rhs1_type)))
3644 TYPE_VECTOR_SUBPARTS (rhs1_type))(!maybe_ne (TYPE_VECTOR_SUBPARTS (lhs_type), TYPE_VECTOR_SUBPARTS
(rhs1_type)))
)
3645 {
3646 lhs_type = TREE_TYPE (lhs_type)((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3646, __FUNCTION__))->typed.type)
;
3647 rhs1_type = TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3647, __FUNCTION__))->typed.type)
;
3648 }
3649 else if (VECTOR_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE) || VECTOR_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE))
3650 {
3651 error ("invalid vector types in nop conversion");
3652 debug_generic_expr (lhs_type);
3653 debug_generic_expr (rhs1_type);
3654 return true;
3655 }
3656
3657 /* Allow conversions from pointer type to integral type only if
3658 there is no sign or zero extension involved.
3659 For targets were the precision of ptrofftype doesn't match that
3660 of pointers we allow conversions to types where
3661 POINTERS_EXTEND_UNSIGNED specifies how that works. */
3662 if ((POINTER_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == POINTER_TYPE ||
((enum tree_code) (lhs_type)->base.code) == REFERENCE_TYPE
)
3663 && INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
)
3664 || (POINTER_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == REFERENCE_TYPE
)
3665 && INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
3666 && (TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3666, __FUNCTION__))->type_common.precision)
>= TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3666, __FUNCTION__))->type_common.precision)
3667#if defined(POINTERS_EXTEND_UNSIGNED1)
3668 || (TYPE_MODE (rhs1_type)((((enum tree_code) ((tree_class_check ((rhs1_type), (tcc_type
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3668, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(rhs1_type) : (rhs1_type)->type_common.mode)
== ptr_mode
3669 && (TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3669, __FUNCTION__))->type_common.precision)
3670 == BITS_PER_WORD((8) * (((global_options.x_ix86_isa_flags & (1UL <<
1)) != 0) ? 8 : 4))
/* word_mode */
3671 || (TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3671, __FUNCTION__))->type_common.precision)
3672 == GET_MODE_PRECISION (Pmode(global_options.x_ix86_pmode == PMODE_DI ? (scalar_int_mode (
(scalar_int_mode::from_int) E_DImode)) : (scalar_int_mode ((scalar_int_mode
::from_int) E_SImode)))
))))
3673#endif
3674 )))
3675 return false;
3676
3677 /* Allow conversion from integral to offset type and vice versa. */
3678 if ((TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) == OFFSET_TYPE
3679 && INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
)
3680 || (INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
3681 && TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) == OFFSET_TYPE))
3682 return false;
3683
3684 /* Otherwise assert we are converting between types of the
3685 same kind. */
3686 if (INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
!= INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
)
3687 {
3688 error ("invalid types in nop conversion");
3689 debug_generic_expr (lhs_type);
3690 debug_generic_expr (rhs1_type);
3691 return true;
3692 }
3693
3694 return false;
3695 }
3696
3697 case ADDR_SPACE_CONVERT_EXPR:
3698 {
3699 if (!POINTER_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == REFERENCE_TYPE
)
|| !POINTER_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == POINTER_TYPE ||
((enum tree_code) (lhs_type)->base.code) == REFERENCE_TYPE
)
3700 || (TYPE_ADDR_SPACE (TREE_TYPE (rhs1_type))((tree_class_check ((((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3700, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3700, __FUNCTION__))->base.u.bits.address_space)
3701 == TYPE_ADDR_SPACE (TREE_TYPE (lhs_type))((tree_class_check ((((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3701, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3701, __FUNCTION__))->base.u.bits.address_space)
))
3702 {
3703 error ("invalid types in address space conversion");
3704 debug_generic_expr (lhs_type);
3705 debug_generic_expr (rhs1_type);
3706 return true;
3707 }
3708
3709 return false;
3710 }
3711
3712 case FIXED_CONVERT_EXPR:
3713 {
3714 if (!valid_fixed_convert_types_p (lhs_type, rhs1_type)
3715 && !valid_fixed_convert_types_p (rhs1_type, lhs_type))
3716 {
3717 error ("invalid types in fixed-point conversion");
3718 debug_generic_expr (lhs_type);
3719 debug_generic_expr (rhs1_type);
3720 return true;
3721 }
3722
3723 return false;
3724 }
3725
3726 case FLOAT_EXPR:
3727 {
3728 if ((!INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
|| !SCALAR_FLOAT_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == REAL_TYPE))
3729 && (!VECTOR_INTEGER_TYPE_P (rhs1_type)((((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE
) && ((enum tree_code) (((contains_struct_check ((rhs1_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3729, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3730 || !VECTOR_FLOAT_TYPE_P (lhs_type)((((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE)
&& ((enum tree_code) (((contains_struct_check ((lhs_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3730, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
))
3731 {
3732 error ("invalid types in conversion to floating-point");
3733 debug_generic_expr (lhs_type);
3734 debug_generic_expr (rhs1_type);
3735 return true;
3736 }
3737
3738 return false;
3739 }
3740
3741 case FIX_TRUNC_EXPR:
3742 {
3743 if ((!INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
|| !SCALAR_FLOAT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == REAL_TYPE))
3744 && (!VECTOR_INTEGER_TYPE_P (lhs_type)((((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE)
&& ((enum tree_code) (((contains_struct_check ((lhs_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3744, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3745 || !VECTOR_FLOAT_TYPE_P (rhs1_type)((((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE
) && ((enum tree_code) (((contains_struct_check ((rhs1_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3745, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
))
3746 {
3747 error ("invalid types in conversion to integer");
3748 debug_generic_expr (lhs_type);
3749 debug_generic_expr (rhs1_type);
3750 return true;
3751 }
3752
3753 return false;
3754 }
3755
3756 case VEC_UNPACK_HI_EXPR:
3757 case VEC_UNPACK_LO_EXPR:
3758 case VEC_UNPACK_FLOAT_HI_EXPR:
3759 case VEC_UNPACK_FLOAT_LO_EXPR:
3760 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3761 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3762 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
3763 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
3764 || (!INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3764, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3764, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3764, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3765 && !SCALAR_FLOAT_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3765, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
)
3766 || (!INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3766, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3766, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3766, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3767 && !SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3767, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
)
3768 || ((rhs_code == VEC_UNPACK_HI_EXPR
3769 || rhs_code == VEC_UNPACK_LO_EXPR)
3770 && (INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3770, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3770, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3770, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3771 != INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3771, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3771, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3771, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
))
3772 || ((rhs_code == VEC_UNPACK_FLOAT_HI_EXPR
3773 || rhs_code == VEC_UNPACK_FLOAT_LO_EXPR)
3774 && (INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3774, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3774, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3774, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3775 || SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3775, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
))
3776 || ((rhs_code == VEC_UNPACK_FIX_TRUNC_HI_EXPR
3777 || rhs_code == VEC_UNPACK_FIX_TRUNC_LO_EXPR)
3778 && (INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3778, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3778, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3778, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3779 || SCALAR_FLOAT_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3779, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
))
3780 || (maybe_ne (GET_MODE_SIZE (element_mode (lhs_type)),
3781 2 * GET_MODE_SIZE (element_mode (rhs1_type)))
3782 && (!VECTOR_BOOLEAN_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3782, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
3783 || !VECTOR_BOOLEAN_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3783, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
))
3784 || maybe_ne (2 * TYPE_VECTOR_SUBPARTS (lhs_type),
3785 TYPE_VECTOR_SUBPARTS (rhs1_type)))
3786 {
3787 error ("type mismatch in %qs expression", code_name);
3788 debug_generic_expr (lhs_type);
3789 debug_generic_expr (rhs1_type);
3790 return true;
3791 }
3792
3793 return false;
3794
3795 case NEGATE_EXPR:
3796 case ABS_EXPR:
3797 case BIT_NOT_EXPR:
3798 case PAREN_EXPR:
3799 case CONJ_EXPR:
3800 /* Disallow pointer and offset types for many of the unary gimple. */
3801 if (POINTER_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == POINTER_TYPE ||
((enum tree_code) (lhs_type)->base.code) == REFERENCE_TYPE
)
3802 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) == OFFSET_TYPE)
3803 {
3804 error ("invalid types for %qs", code_name);
3805 debug_generic_expr (lhs_type);
3806 debug_generic_expr (rhs1_type);
3807 return true;
3808 }
3809 break;
3810
3811 case ABSU_EXPR:
3812 if (!ANY_INTEGRAL_TYPE_P (lhs_type)((((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
) || ((((enum tree_code) (lhs_type)->base.code) == COMPLEX_TYPE
|| (((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE
)) && (((enum tree_code) (((contains_struct_check ((lhs_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3812, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3812, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3812, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)))
3813 || !TYPE_UNSIGNED (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3813, __FUNCTION__))->base.u.bits.unsigned_flag)
3814 || !ANY_INTEGRAL_TYPE_P (rhs1_type)((((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
) || ((((enum tree_code) (rhs1_type)->base.code) == COMPLEX_TYPE
|| (((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE
)) && (((enum tree_code) (((contains_struct_check ((rhs1_type
), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3814, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3814, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3814, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)))
3815 || TYPE_UNSIGNED (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3815, __FUNCTION__))->base.u.bits.unsigned_flag)
3816 || element_precision (lhs_type) != element_precision (rhs1_type))
3817 {
3818 error ("invalid types for %qs", code_name);
3819 debug_generic_expr (lhs_type);
3820 debug_generic_expr (rhs1_type);
3821 return true;
3822 }
3823 return false;
3824
3825 case VEC_DUPLICATE_EXPR:
3826 if (TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
3827 || !useless_type_conversion_p (TREE_TYPE (lhs_type)((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3827, __FUNCTION__))->typed.type)
, rhs1_type))
3828 {
3829 error ("%qs should be from a scalar to a like vector", code_name);
3830 debug_generic_expr (lhs_type);
3831 debug_generic_expr (rhs1_type);
3832 return true;
3833 }
3834 return false;
3835
3836 default:
3837 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3837, __FUNCTION__))
;
3838 }
3839
3840 /* For the remaining codes assert there is no conversion involved. */
3841 if (!useless_type_conversion_p (lhs_type, rhs1_type))
3842 {
3843 error ("non-trivial conversion in unary operation");
3844 debug_generic_expr (lhs_type);
3845 debug_generic_expr (rhs1_type);
3846 return true;
3847 }
3848
3849 return false;
3850}
3851
3852/* Verify a gimple assignment statement STMT with a binary rhs.
3853 Returns true if anything is wrong. */
3854
3855static bool
3856verify_gimple_assign_binary (gassign *stmt)
3857{
3858 enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
3859 tree lhs = gimple_assign_lhs (stmt);
3860 tree lhs_type = TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3860, __FUNCTION__))->typed.type)
;
3861 tree rhs1 = gimple_assign_rhs1 (stmt);
3862 tree rhs1_type = TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3862, __FUNCTION__))->typed.type)
;
3863 tree rhs2 = gimple_assign_rhs2 (stmt);
3864 tree rhs2_type = TREE_TYPE (rhs2)((contains_struct_check ((rhs2), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3864, __FUNCTION__))->typed.type)
;
3865
3866 if (!is_gimple_reg (lhs))
3867 {
3868 error ("non-register as LHS of binary operation");
3869 return true;
3870 }
3871
3872 if (!is_gimple_val (rhs1)
3873 || !is_gimple_val (rhs2))
3874 {
3875 error ("invalid operands in binary operation");
3876 return true;
3877 }
3878
3879 const char* const code_name = get_tree_code_name (rhs_code);
3880
3881 /* First handle operations that involve different types. */
3882 switch (rhs_code)
3883 {
3884 case COMPLEX_EXPR:
3885 {
3886 if (TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != COMPLEX_TYPE
3887 || !(INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
3888 || SCALAR_FLOAT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == REAL_TYPE))
3889 || !(INTEGRAL_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == INTEGER_TYPE
)
3890 || SCALAR_FLOAT_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == REAL_TYPE)))
3891 {
3892 error ("type mismatch in %qs", code_name);
3893 debug_generic_expr (lhs_type);
3894 debug_generic_expr (rhs1_type);
3895 debug_generic_expr (rhs2_type);
3896 return true;
3897 }
3898
3899 return false;
3900 }
3901
3902 case LSHIFT_EXPR:
3903 case RSHIFT_EXPR:
3904 case LROTATE_EXPR:
3905 case RROTATE_EXPR:
3906 {
3907 /* Shifts and rotates are ok on integral types, fixed point
3908 types and integer vector types. */
3909 if ((!INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
3910 && !FIXED_POINT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == FIXED_POINT_TYPE
)
3911 && !(TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE
3912 && INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3912, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3912, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3912, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
))
3913 || (!INTEGRAL_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == INTEGER_TYPE
)
3914 /* Vector shifts of vectors are also ok. */
3915 && !(TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE
3916 && INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3916, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3916, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3916, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3917 && TREE_CODE (rhs2_type)((enum tree_code) (rhs2_type)->base.code) == VECTOR_TYPE
3918 && INTEGRAL_TYPE_P (TREE_TYPE (rhs2_type))(((enum tree_code) (((contains_struct_check ((rhs2_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3918, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs2_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3918, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs2_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3918, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
))
3919 || !useless_type_conversion_p (lhs_type, rhs1_type))
3920 {
3921 error ("type mismatch in %qs", code_name);
3922 debug_generic_expr (lhs_type);
3923 debug_generic_expr (rhs1_type);
3924 debug_generic_expr (rhs2_type);
3925 return true;
3926 }
3927
3928 return false;
3929 }
3930
3931 case WIDEN_LSHIFT_EXPR:
3932 {
3933 if (!INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
3934 || !INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
3935 || TREE_CODE (rhs2)((enum tree_code) (rhs2)->base.code) != INTEGER_CST
3936 || (2 * TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3936, __FUNCTION__))->type_common.precision)
> TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3936, __FUNCTION__))->type_common.precision)
))
3937 {
3938 error ("type mismatch in %qs", code_name);
3939 debug_generic_expr (lhs_type);
3940 debug_generic_expr (rhs1_type);
3941 debug_generic_expr (rhs2_type);
3942 return true;
3943 }
3944
3945 return false;
3946 }
3947
3948 case VEC_WIDEN_LSHIFT_HI_EXPR:
3949 case VEC_WIDEN_LSHIFT_LO_EXPR:
3950 {
3951 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
3952 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
3953 || !INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3953, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3953, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3953, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3954 || !INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3954, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3954, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3954, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
3955 || TREE_CODE (rhs2)((enum tree_code) (rhs2)->base.code) != INTEGER_CST
3956 || (2 * TYPE_PRECISION (TREE_TYPE (rhs1_type))((tree_class_check ((((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3956, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3956, __FUNCTION__))->type_common.precision)
3957 > TYPE_PRECISION (TREE_TYPE (lhs_type))((tree_class_check ((((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3957, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3957, __FUNCTION__))->type_common.precision)
))
3958 {
3959 error ("type mismatch in %qs", code_name);
3960 debug_generic_expr (lhs_type);
3961 debug_generic_expr (rhs1_type);
3962 debug_generic_expr (rhs2_type);
3963 return true;
3964 }
3965
3966 return false;
3967 }
3968
3969 case WIDEN_PLUS_EXPR:
3970 case WIDEN_MINUS_EXPR:
3971 case PLUS_EXPR:
3972 case MINUS_EXPR:
3973 {
3974 tree lhs_etype = lhs_type;
3975 tree rhs1_etype = rhs1_type;
3976 tree rhs2_etype = rhs2_type;
3977 if (TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE)
3978 {
3979 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
3980 || TREE_CODE (rhs2_type)((enum tree_code) (rhs2_type)->base.code) != VECTOR_TYPE)
3981 {
3982 error ("invalid non-vector operands to %qs", code_name);
3983 return true;
3984 }
3985 lhs_etype = TREE_TYPE (lhs_type)((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3985, __FUNCTION__))->typed.type)
;
3986 rhs1_etype = TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3986, __FUNCTION__))->typed.type)
;
3987 rhs2_etype = TREE_TYPE (rhs2_type)((contains_struct_check ((rhs2_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 3987, __FUNCTION__))->typed.type)
;
3988 }
3989 if (POINTER_TYPE_P (lhs_etype)(((enum tree_code) (lhs_etype)->base.code) == POINTER_TYPE
|| ((enum tree_code) (lhs_etype)->base.code) == REFERENCE_TYPE
)
3990 || POINTER_TYPE_P (rhs1_etype)(((enum tree_code) (rhs1_etype)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs1_etype)->base.code) == REFERENCE_TYPE
)
3991 || POINTER_TYPE_P (rhs2_etype)(((enum tree_code) (rhs2_etype)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs2_etype)->base.code) == REFERENCE_TYPE
)
)
3992 {
3993 error ("invalid (pointer) operands %qs", code_name);
3994 return true;
3995 }
3996
3997 /* Continue with generic binary expression handling. */
3998 break;
3999 }
4000
4001 case POINTER_PLUS_EXPR:
4002 {
4003 if (!POINTER_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == REFERENCE_TYPE
)
4004 || !useless_type_conversion_p (lhs_type, rhs1_type)
4005 || !ptrofftype_p (rhs2_type))
4006 {
4007 error ("type mismatch in %qs", code_name);
4008 debug_generic_stmt (lhs_type);
4009 debug_generic_stmt (rhs1_type);
4010 debug_generic_stmt (rhs2_type);
4011 return true;
4012 }
4013
4014 return false;
4015 }
4016
4017 case POINTER_DIFF_EXPR:
4018 {
4019 if (!POINTER_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == REFERENCE_TYPE
)
4020 || !POINTER_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == POINTER_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == REFERENCE_TYPE
)
4021 /* Because we special-case pointers to void we allow difference
4022 of arbitrary pointers with the same mode. */
4023 || TYPE_MODE (rhs1_type)((((enum tree_code) ((tree_class_check ((rhs1_type), (tcc_type
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4023, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(rhs1_type) : (rhs1_type)->type_common.mode)
!= TYPE_MODE (rhs2_type)((((enum tree_code) ((tree_class_check ((rhs2_type), (tcc_type
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4023, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(rhs2_type) : (rhs2_type)->type_common.mode)
4024 || !INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
4025 || TYPE_UNSIGNED (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4025, __FUNCTION__))->base.u.bits.unsigned_flag)
4026 || TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4026, __FUNCTION__))->type_common.precision)
!= TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4026, __FUNCTION__))->type_common.precision)
)
4027 {
4028 error ("type mismatch in %qs", code_name);
4029 debug_generic_stmt (lhs_type);
4030 debug_generic_stmt (rhs1_type);
4031 debug_generic_stmt (rhs2_type);
4032 return true;
4033 }
4034
4035 return false;
4036 }
4037
4038 case TRUTH_ANDIF_EXPR:
4039 case TRUTH_ORIF_EXPR:
4040 case TRUTH_AND_EXPR:
4041 case TRUTH_OR_EXPR:
4042 case TRUTH_XOR_EXPR:
4043
4044 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4044, __FUNCTION__))
;
4045
4046 case LT_EXPR:
4047 case LE_EXPR:
4048 case GT_EXPR:
4049 case GE_EXPR:
4050 case EQ_EXPR:
4051 case NE_EXPR:
4052 case UNORDERED_EXPR:
4053 case ORDERED_EXPR:
4054 case UNLT_EXPR:
4055 case UNLE_EXPR:
4056 case UNGT_EXPR:
4057 case UNGE_EXPR:
4058 case UNEQ_EXPR:
4059 case LTGT_EXPR:
4060 /* Comparisons are also binary, but the result type is not
4061 connected to the operand types. */
4062 return verify_gimple_comparison (lhs_type, rhs1, rhs2, rhs_code);
4063
4064 case WIDEN_MULT_EXPR:
4065 if (TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != INTEGER_TYPE)
4066 return true;
4067 return ((2 * TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4067, __FUNCTION__))->type_common.precision)
> TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4067, __FUNCTION__))->type_common.precision)
)
4068 || (TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4068, __FUNCTION__))->type_common.precision)
!= TYPE_PRECISION (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4068, __FUNCTION__))->type_common.precision)
));
4069
4070 case WIDEN_SUM_EXPR:
4071 {
4072 if (((TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4073 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE)
4074 && ((!INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
4075 && !SCALAR_FLOAT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == REAL_TYPE))
4076 || (!INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
4077 && !SCALAR_FLOAT_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == REAL_TYPE))))
4078 || !useless_type_conversion_p (lhs_type, rhs2_type)
4079 || maybe_lt (GET_MODE_SIZE (element_mode (rhs2_type)),
4080 2 * GET_MODE_SIZE (element_mode (rhs1_type))))
4081 {
4082 error ("type mismatch in %qs", code_name);
4083 debug_generic_expr (lhs_type);
4084 debug_generic_expr (rhs1_type);
4085 debug_generic_expr (rhs2_type);
4086 return true;
4087 }
4088 return false;
4089 }
4090
4091 case VEC_WIDEN_MINUS_HI_EXPR:
4092 case VEC_WIDEN_MINUS_LO_EXPR:
4093 case VEC_WIDEN_PLUS_HI_EXPR:
4094 case VEC_WIDEN_PLUS_LO_EXPR:
4095 case VEC_WIDEN_MULT_HI_EXPR:
4096 case VEC_WIDEN_MULT_LO_EXPR:
4097 case VEC_WIDEN_MULT_EVEN_EXPR:
4098 case VEC_WIDEN_MULT_ODD_EXPR:
4099 {
4100 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4101 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
4102 || !types_compatible_p (rhs1_type, rhs2_type)
4103 || maybe_ne (GET_MODE_SIZE (element_mode (lhs_type)),
4104 2 * GET_MODE_SIZE (element_mode (rhs1_type))))
4105 {
4106 error ("type mismatch in %qs", code_name);
4107 debug_generic_expr (lhs_type);
4108 debug_generic_expr (rhs1_type);
4109 debug_generic_expr (rhs2_type);
4110 return true;
4111 }
4112 return false;
4113 }
4114
4115 case VEC_PACK_TRUNC_EXPR:
4116 /* ??? We currently use VEC_PACK_TRUNC_EXPR to simply concat
4117 vector boolean types. */
4118 if (VECTOR_BOOLEAN_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4118, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
4119 && VECTOR_BOOLEAN_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4119, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
4120 && types_compatible_p (rhs1_type, rhs2_type)
4121 && known_eq (TYPE_VECTOR_SUBPARTS (lhs_type),(!maybe_ne (TYPE_VECTOR_SUBPARTS (lhs_type), 2 * TYPE_VECTOR_SUBPARTS
(rhs1_type)))
4122 2 * TYPE_VECTOR_SUBPARTS (rhs1_type))(!maybe_ne (TYPE_VECTOR_SUBPARTS (lhs_type), 2 * TYPE_VECTOR_SUBPARTS
(rhs1_type)))
)
4123 return false;
4124
4125 /* Fallthru. */
4126 case VEC_PACK_SAT_EXPR:
4127 case VEC_PACK_FIX_TRUNC_EXPR:
4128 {
4129 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4130 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
4131 || !((rhs_code == VEC_PACK_FIX_TRUNC_EXPR
4132 && SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4132, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
4133 && INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4133, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4133, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4133, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
)
4134 || (INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4134, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4134, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4134, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
4135 == INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4135, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4135, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((lhs_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4135, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
))
4136 || !types_compatible_p (rhs1_type, rhs2_type)
4137 || maybe_ne (GET_MODE_SIZE (element_mode (rhs1_type)),
4138 2 * GET_MODE_SIZE (element_mode (lhs_type)))
4139 || maybe_ne (2 * TYPE_VECTOR_SUBPARTS (rhs1_type),
4140 TYPE_VECTOR_SUBPARTS (lhs_type)))
4141 {
4142 error ("type mismatch in %qs", code_name);
4143 debug_generic_expr (lhs_type);
4144 debug_generic_expr (rhs1_type);
4145 debug_generic_expr (rhs2_type);
4146 return true;
4147 }
4148
4149 return false;
4150 }
4151
4152 case VEC_PACK_FLOAT_EXPR:
4153 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4154 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
4155 || !INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type))(((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4155, __FUNCTION__))->typed.type))->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4155, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (((contains_struct_check ((rhs1_type), (
TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4155, __FUNCTION__))->typed.type))->base.code) == INTEGER_TYPE
)
4156 || !SCALAR_FLOAT_TYPE_P (TREE_TYPE (lhs_type))(((enum tree_code) (((contains_struct_check ((lhs_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4156, __FUNCTION__))->typed.type))->base.code) == REAL_TYPE
)
4157 || !types_compatible_p (rhs1_type, rhs2_type)
4158 || maybe_ne (GET_MODE_SIZE (element_mode (rhs1_type)),
4159 2 * GET_MODE_SIZE (element_mode (lhs_type)))
4160 || maybe_ne (2 * TYPE_VECTOR_SUBPARTS (rhs1_type),
4161 TYPE_VECTOR_SUBPARTS (lhs_type)))
4162 {
4163 error ("type mismatch in %qs", code_name);
4164 debug_generic_expr (lhs_type);
4165 debug_generic_expr (rhs1_type);
4166 debug_generic_expr (rhs2_type);
4167 return true;
4168 }
4169
4170 return false;
4171
4172 case MULT_EXPR:
4173 case MULT_HIGHPART_EXPR:
4174 case TRUNC_DIV_EXPR:
4175 case CEIL_DIV_EXPR:
4176 case FLOOR_DIV_EXPR:
4177 case ROUND_DIV_EXPR:
4178 case TRUNC_MOD_EXPR:
4179 case CEIL_MOD_EXPR:
4180 case FLOOR_MOD_EXPR:
4181 case ROUND_MOD_EXPR:
4182 case RDIV_EXPR:
4183 case EXACT_DIV_EXPR:
4184 /* Disallow pointer and offset types for many of the binary gimple. */
4185 if (POINTER_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == POINTER_TYPE ||
((enum tree_code) (lhs_type)->base.code) == REFERENCE_TYPE
)
4186 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) == OFFSET_TYPE)
4187 {
4188 error ("invalid types for %qs", code_name);
4189 debug_generic_expr (lhs_type);
4190 debug_generic_expr (rhs1_type);
4191 debug_generic_expr (rhs2_type);
4192 return true;
4193 }
4194 /* Continue with generic binary expression handling. */
4195 break;
4196
4197 case MIN_EXPR:
4198 case MAX_EXPR:
4199 case BIT_IOR_EXPR:
4200 case BIT_XOR_EXPR:
4201 case BIT_AND_EXPR:
4202 /* Continue with generic binary expression handling. */
4203 break;
4204
4205 case VEC_SERIES_EXPR:
4206 if (!useless_type_conversion_p (rhs1_type, rhs2_type))
4207 {
4208 error ("type mismatch in %qs", code_name);
4209 debug_generic_expr (rhs1_type);
4210 debug_generic_expr (rhs2_type);
4211 return true;
4212 }
4213 if (TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE
4214 || !useless_type_conversion_p (TREE_TYPE (lhs_type)((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4214, __FUNCTION__))->typed.type)
, rhs1_type))
4215 {
4216 error ("vector type expected in %qs", code_name);
4217 debug_generic_expr (lhs_type);
4218 return true;
4219 }
4220 return false;
4221
4222 default:
4223 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4223, __FUNCTION__))
;
4224 }
4225
4226 if (!useless_type_conversion_p (lhs_type, rhs1_type)
4227 || !useless_type_conversion_p (lhs_type, rhs2_type))
4228 {
4229 error ("type mismatch in binary expression");
4230 debug_generic_stmt (lhs_type);
4231 debug_generic_stmt (rhs1_type);
4232 debug_generic_stmt (rhs2_type);
4233 return true;
4234 }
4235
4236 return false;
4237}
4238
4239/* Verify a gimple assignment statement STMT with a ternary rhs.
4240 Returns true if anything is wrong. */
4241
4242static bool
4243verify_gimple_assign_ternary (gassign *stmt)
4244{
4245 enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
4246 tree lhs = gimple_assign_lhs (stmt);
4247 tree lhs_type = TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4247, __FUNCTION__))->typed.type)
;
4248 tree rhs1 = gimple_assign_rhs1 (stmt);
4249 tree rhs1_type = TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4249, __FUNCTION__))->typed.type)
;
4250 tree rhs2 = gimple_assign_rhs2 (stmt);
4251 tree rhs2_type = TREE_TYPE (rhs2)((contains_struct_check ((rhs2), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4251, __FUNCTION__))->typed.type)
;
4252 tree rhs3 = gimple_assign_rhs3 (stmt);
4253 tree rhs3_type = TREE_TYPE (rhs3)((contains_struct_check ((rhs3), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4253, __FUNCTION__))->typed.type)
;
4254
4255 if (!is_gimple_reg (lhs))
4256 {
4257 error ("non-register as LHS of ternary operation");
4258 return true;
4259 }
4260
4261 if ((rhs_code == COND_EXPR
4262 ? !is_gimple_condexpr (rhs1) : !is_gimple_val (rhs1))
4263 || !is_gimple_val (rhs2)
4264 || !is_gimple_val (rhs3))
4265 {
4266 error ("invalid operands in ternary operation");
4267 return true;
4268 }
4269
4270 const char* const code_name = get_tree_code_name (rhs_code);
4271
4272 /* First handle operations that involve different types. */
4273 switch (rhs_code)
4274 {
4275 case WIDEN_MULT_PLUS_EXPR:
4276 case WIDEN_MULT_MINUS_EXPR:
4277 if ((!INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
4278 && !FIXED_POINT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == FIXED_POINT_TYPE
)
)
4279 || !useless_type_conversion_p (rhs1_type, rhs2_type)
4280 || !useless_type_conversion_p (lhs_type, rhs3_type)
4281 || 2 * TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4281, __FUNCTION__))->type_common.precision)
> TYPE_PRECISION (lhs_type)((tree_class_check ((lhs_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4281, __FUNCTION__))->type_common.precision)
4282 || TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4282, __FUNCTION__))->type_common.precision)
!= TYPE_PRECISION (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4282, __FUNCTION__))->type_common.precision)
)
4283 {
4284 error ("type mismatch in %qs", code_name);
4285 debug_generic_expr (lhs_type);
4286 debug_generic_expr (rhs1_type);
4287 debug_generic_expr (rhs2_type);
4288 debug_generic_expr (rhs3_type);
4289 return true;
4290 }
4291 break;
4292
4293 case VEC_COND_EXPR:
4294 if (!VECTOR_BOOLEAN_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE &&
((enum tree_code) (((contains_struct_check ((rhs1_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4294, __FUNCTION__))->typed.type))->base.code) == BOOLEAN_TYPE
)
4295 || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type),
4296 TYPE_VECTOR_SUBPARTS (lhs_type)))
4297 {
4298 error ("the first argument of a %qs must be of a "
4299 "boolean vector type of the same number of elements "
4300 "as the result", code_name);
4301 debug_generic_expr (lhs_type);
4302 debug_generic_expr (rhs1_type);
4303 return true;
4304 }
4305 if (!is_gimple_val (rhs1))
4306 return true;
4307 /* Fallthrough. */
4308 case COND_EXPR:
4309 if (!is_gimple_val (rhs1)
4310 && verify_gimple_comparison (TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4310, __FUNCTION__))->typed.type)
,
4311 TREE_OPERAND (rhs1, 0)(*((const_cast<tree*> (tree_operand_check ((rhs1), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4311, __FUNCTION__)))))
,
4312 TREE_OPERAND (rhs1, 1)(*((const_cast<tree*> (tree_operand_check ((rhs1), (1),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4312, __FUNCTION__)))))
,
4313 TREE_CODE (rhs1)((enum tree_code) (rhs1)->base.code)))
4314 return true;
4315 if (!useless_type_conversion_p (lhs_type, rhs2_type)
4316 || !useless_type_conversion_p (lhs_type, rhs3_type))
4317 {
4318 error ("type mismatch in %qs", code_name);
4319 debug_generic_expr (lhs_type);
4320 debug_generic_expr (rhs2_type);
4321 debug_generic_expr (rhs3_type);
4322 return true;
4323 }
4324 break;
4325
4326 case VEC_PERM_EXPR:
4327 if (!useless_type_conversion_p (lhs_type, rhs1_type)
4328 || !useless_type_conversion_p (lhs_type, rhs2_type))
4329 {
4330 error ("type mismatch in %qs", code_name);
4331 debug_generic_expr (lhs_type);
4332 debug_generic_expr (rhs1_type);
4333 debug_generic_expr (rhs2_type);
4334 debug_generic_expr (rhs3_type);
4335 return true;
4336 }
4337
4338 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4339 || TREE_CODE (rhs2_type)((enum tree_code) (rhs2_type)->base.code) != VECTOR_TYPE
4340 || TREE_CODE (rhs3_type)((enum tree_code) (rhs3_type)->base.code) != VECTOR_TYPE)
4341 {
4342 error ("vector types expected in %qs", code_name);
4343 debug_generic_expr (lhs_type);
4344 debug_generic_expr (rhs1_type);
4345 debug_generic_expr (rhs2_type);
4346 debug_generic_expr (rhs3_type);
4347 return true;
4348 }
4349
4350 if (maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type),
4351 TYPE_VECTOR_SUBPARTS (rhs2_type))
4352 || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs2_type),
4353 TYPE_VECTOR_SUBPARTS (rhs3_type))
4354 || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs3_type),
4355 TYPE_VECTOR_SUBPARTS (lhs_type)))
4356 {
4357 error ("vectors with different element number found in %qs",
4358 code_name);
4359 debug_generic_expr (lhs_type);
4360 debug_generic_expr (rhs1_type);
4361 debug_generic_expr (rhs2_type);
4362 debug_generic_expr (rhs3_type);
4363 return true;
4364 }
4365
4366 if (TREE_CODE (TREE_TYPE (rhs3_type))((enum tree_code) (((contains_struct_check ((rhs3_type), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4366, __FUNCTION__))->typed.type))->base.code)
!= INTEGER_TYPE
4367 || (TREE_CODE (rhs3)((enum tree_code) (rhs3)->base.code) != VECTOR_CST
4368 && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE(as_a <scalar_int_mode> ((tree_class_check ((((contains_struct_check
((rhs3_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4369, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4369, __FUNCTION__))->type_common.mode))
4369 (TREE_TYPE (rhs3_type))(as_a <scalar_int_mode> ((tree_class_check ((((contains_struct_check
((rhs3_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4369, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4369, __FUNCTION__))->type_common.mode))
)
4370 != GET_MODE_BITSIZE (SCALAR_TYPE_MODE(as_a <scalar_mode> ((tree_class_check ((((contains_struct_check
((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4371, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4371, __FUNCTION__))->type_common.mode))
4371 (TREE_TYPE (rhs1_type))(as_a <scalar_mode> ((tree_class_check ((((contains_struct_check
((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4371, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4371, __FUNCTION__))->type_common.mode))
))))
4372 {
4373 error ("invalid mask type in %qs", code_name);
4374 debug_generic_expr (lhs_type);
4375 debug_generic_expr (rhs1_type);
4376 debug_generic_expr (rhs2_type);
4377 debug_generic_expr (rhs3_type);
4378 return true;
4379 }
4380
4381 return false;
4382
4383 case SAD_EXPR:
4384 if (!useless_type_conversion_p (rhs1_type, rhs2_type)
4385 || !useless_type_conversion_p (lhs_type, rhs3_type)
4386 || 2 * GET_MODE_UNIT_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type)))((unsigned short) (mode_to_unit_size (((((enum tree_code) ((tree_class_check
((((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4386, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4386, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4386, __FUNCTION__))->typed.type)) : (((contains_struct_check
((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4386, __FUNCTION__))->typed.type))->type_common.mode)
) * (8)))
4387 > GET_MODE_UNIT_BITSIZE (TYPE_MODE (TREE_TYPE (lhs_type)))((unsigned short) (mode_to_unit_size (((((enum tree_code) ((tree_class_check
((((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4387, __FUNCTION__))->typed.type)), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4387, __FUNCTION__)))->base.code) == VECTOR_TYPE) ? vector_type_mode
(((contains_struct_check ((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4387, __FUNCTION__))->typed.type)) : (((contains_struct_check
((lhs_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4387, __FUNCTION__))->typed.type))->type_common.mode)
) * (8)))
)
4388 {
4389 error ("type mismatch in %qs", code_name);
4390 debug_generic_expr (lhs_type);
4391 debug_generic_expr (rhs1_type);
4392 debug_generic_expr (rhs2_type);
4393 debug_generic_expr (rhs3_type);
4394 return true;
4395 }
4396
4397 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4398 || TREE_CODE (rhs2_type)((enum tree_code) (rhs2_type)->base.code) != VECTOR_TYPE
4399 || TREE_CODE (rhs3_type)((enum tree_code) (rhs3_type)->base.code) != VECTOR_TYPE)
4400 {
4401 error ("vector types expected in %qs", code_name);
4402 debug_generic_expr (lhs_type);
4403 debug_generic_expr (rhs1_type);
4404 debug_generic_expr (rhs2_type);
4405 debug_generic_expr (rhs3_type);
4406 return true;
4407 }
4408
4409 return false;
4410
4411 case BIT_INSERT_EXPR:
4412 if (! useless_type_conversion_p (lhs_type, rhs1_type))
4413 {
4414 error ("type mismatch in %qs", code_name);
4415 debug_generic_expr (lhs_type);
4416 debug_generic_expr (rhs1_type);
4417 return true;
4418 }
4419 if (! ((INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
4420 && INTEGRAL_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs2_type)->base.code) == INTEGER_TYPE
)
)
4421 /* Vector element insert. */
4422 || (VECTOR_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE)
4423 && types_compatible_p (TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4423, __FUNCTION__))->typed.type)
, rhs2_type))
4424 /* Aligned sub-vector insert. */
4425 || (VECTOR_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE)
4426 && VECTOR_TYPE_P (rhs2_type)(((enum tree_code) (rhs2_type)->base.code) == VECTOR_TYPE)
4427 && types_compatible_p (TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4427, __FUNCTION__))->typed.type)
,
4428 TREE_TYPE (rhs2_type)((contains_struct_check ((rhs2_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4428, __FUNCTION__))->typed.type)
)
4429 && multiple_p (TYPE_VECTOR_SUBPARTS (rhs1_type),
4430 TYPE_VECTOR_SUBPARTS (rhs2_type))
4431 && multiple_of_p (bitsizetypesizetype_tab[(int) stk_bitsizetype], rhs3, TYPE_SIZE (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4431, __FUNCTION__))->type_common.size)
))))
4432 {
4433 error ("not allowed type combination in %qs", code_name);
4434 debug_generic_expr (rhs1_type);
4435 debug_generic_expr (rhs2_type);
4436 return true;
4437 }
4438 if (! tree_fits_uhwi_p (rhs3)
4439 || ! types_compatible_p (bitsizetypesizetype_tab[(int) stk_bitsizetype], TREE_TYPE (rhs3)((contains_struct_check ((rhs3), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4439, __FUNCTION__))->typed.type)
)
4440 || ! tree_fits_uhwi_p (TYPE_SIZE (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4440, __FUNCTION__))->type_common.size)
))
4441 {
4442 error ("invalid position or size in %qs", code_name);
4443 return true;
4444 }
4445 if (INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
4446 && !type_has_mode_precision_p (rhs1_type))
4447 {
4448 error ("%qs into non-mode-precision operand", code_name);
4449 return true;
4450 }
4451 if (INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
)
4452 {
4453 unsigned HOST_WIDE_INTlong bitpos = tree_to_uhwi (rhs3);
4454 if (bitpos >= TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4454, __FUNCTION__))->type_common.precision)
4455 || (bitpos + TYPE_PRECISION (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4455, __FUNCTION__))->type_common.precision)
4456 > TYPE_PRECISION (rhs1_type)((tree_class_check ((rhs1_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4456, __FUNCTION__))->type_common.precision)
))
4457 {
4458 error ("insertion out of range in %qs", code_name);
4459 return true;
4460 }
4461 }
4462 else if (VECTOR_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE))
4463 {
4464 unsigned HOST_WIDE_INTlong bitpos = tree_to_uhwi (rhs3);
4465 unsigned HOST_WIDE_INTlong bitsize = tree_to_uhwi (TYPE_SIZE (rhs2_type)((tree_class_check ((rhs2_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4465, __FUNCTION__))->type_common.size)
);
4466 if (bitpos % bitsize != 0)
4467 {
4468 error ("%qs not at element boundary", code_name);
4469 return true;
4470 }
4471 }
4472 return false;
4473
4474 case DOT_PROD_EXPR:
4475 {
4476 if (((TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) != VECTOR_TYPE
4477 || TREE_CODE (lhs_type)((enum tree_code) (lhs_type)->base.code) != VECTOR_TYPE)
4478 && ((!INTEGRAL_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (rhs1_type)->base.code) == INTEGER_TYPE
)
4479 && !SCALAR_FLOAT_TYPE_P (rhs1_type)(((enum tree_code) (rhs1_type)->base.code) == REAL_TYPE))
4480 || (!INTEGRAL_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (lhs_type)->base.code) == INTEGER_TYPE
)
4481 && !SCALAR_FLOAT_TYPE_P (lhs_type)(((enum tree_code) (lhs_type)->base.code) == REAL_TYPE))))
4482 /* rhs1_type and rhs2_type may differ in sign. */
4483 || !tree_nop_conversion_p (rhs1_type, rhs2_type)
4484 || !useless_type_conversion_p (lhs_type, rhs3_type)
4485 || maybe_lt (GET_MODE_SIZE (element_mode (rhs3_type)),
4486 2 * GET_MODE_SIZE (element_mode (rhs1_type))))
4487 {
4488 error ("type mismatch in %qs", code_name);
4489 debug_generic_expr (lhs_type);
4490 debug_generic_expr (rhs1_type);
4491 debug_generic_expr (rhs2_type);
4492 return true;
4493 }
4494 return false;
4495 }
4496
4497 case REALIGN_LOAD_EXPR:
4498 /* FIXME. */
4499 return false;
4500
4501 default:
4502 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4502, __FUNCTION__))
;
4503 }
4504 return false;
4505}
4506
4507/* Verify a gimple assignment statement STMT with a single rhs.
4508 Returns true if anything is wrong. */
4509
4510static bool
4511verify_gimple_assign_single (gassign *stmt)
4512{
4513 enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
4514 tree lhs = gimple_assign_lhs (stmt);
4515 tree lhs_type = TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4515, __FUNCTION__))->typed.type)
;
4516 tree rhs1 = gimple_assign_rhs1 (stmt);
4517 tree rhs1_type = TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4517, __FUNCTION__))->typed.type)
;
4518 bool res = false;
4519
4520 const char* const code_name = get_tree_code_name (rhs_code);
4521
4522 if (!useless_type_conversion_p (lhs_type, rhs1_type))
4523 {
4524 error ("non-trivial conversion in %qs", code_name);
4525 debug_generic_expr (lhs_type);
4526 debug_generic_expr (rhs1_type);
4527 return true;
4528 }
4529
4530 if (gimple_clobber_p (stmt)
4531 && !(DECL_P (lhs)(tree_code_type[(int) (((enum tree_code) (lhs)->base.code)
)] == tcc_declaration)
|| TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == MEM_REF))
4532 {
4533 error ("%qs LHS in clobber statement",
4534 get_tree_code_name (TREE_CODE (lhs)((enum tree_code) (lhs)->base.code)));
4535 debug_generic_expr (lhs);
4536 return true;
4537 }
4538
4539 if (TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == WITH_SIZE_EXPR)
4540 {
4541 error ("%qs LHS in assignment statement",
4542 get_tree_code_name (TREE_CODE (lhs)((enum tree_code) (lhs)->base.code)));
4543 debug_generic_expr (lhs);
4544 return true;
4545 }
4546
4547 if (handled_component_p (lhs)
4548 || TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == MEM_REF
4549 || TREE_CODE (lhs)((enum tree_code) (lhs)->base.code) == TARGET_MEM_REF)
4550 res |= verify_types_in_gimple_reference (lhs, true);
4551
4552 /* Special codes we cannot handle via their class. */
4553 switch (rhs_code)
4554 {
4555 case ADDR_EXPR:
4556 {
4557 tree op = TREE_OPERAND (rhs1, 0)(*((const_cast<tree*> (tree_operand_check ((rhs1), (0),
"/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4557, __FUNCTION__)))))
;
4558 if (!is_gimple_addressable (op))
4559 {
4560 error ("invalid operand in %qs", code_name);
4561 return true;
4562 }
4563
4564 /* Technically there is no longer a need for matching types, but
4565 gimple hygiene asks for this check. In LTO we can end up
4566 combining incompatible units and thus end up with addresses
4567 of globals that change their type to a common one. */
4568 if (!in_lto_pglobal_options.x_in_lto_p
4569 && !types_compatible_p (TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4569, __FUNCTION__))->typed.type)
,
4570 TREE_TYPE (TREE_TYPE (rhs1))((contains_struct_check ((((contains_struct_check ((rhs1), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4570, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4570, __FUNCTION__))->typed.type)
)
4571 && !one_pointer_to_useless_type_conversion_p (TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4571, __FUNCTION__))->typed.type)
,
4572 TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4572, __FUNCTION__))->typed.type)
))
4573 {
4574 error ("type mismatch in %qs", code_name);
4575 debug_generic_stmt (TREE_TYPE (rhs1)((contains_struct_check ((rhs1), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4575, __FUNCTION__))->typed.type)
);
4576 debug_generic_stmt (TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4576, __FUNCTION__))->typed.type)
);
4577 return true;
4578 }
4579
4580 return (verify_address (rhs1, true)
4581 || verify_types_in_gimple_reference (op, true));
4582 }
4583
4584 /* tcc_reference */
4585 case INDIRECT_REF:
4586 error ("%qs in gimple IL", code_name);
4587 return true;
4588
4589 case COMPONENT_REF:
4590 case BIT_FIELD_REF:
4591 case ARRAY_REF:
4592 case ARRAY_RANGE_REF:
4593 case VIEW_CONVERT_EXPR:
4594 case REALPART_EXPR:
4595 case IMAGPART_EXPR:
4596 case TARGET_MEM_REF:
4597 case MEM_REF:
4598 if (!is_gimple_reg (lhs)
4599 && is_gimple_reg_type (TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4599, __FUNCTION__))->typed.type)
))
4600 {
4601 error ("invalid RHS for gimple memory store: %qs", code_name);
4602 debug_generic_stmt (lhs);
4603 debug_generic_stmt (rhs1);
4604 return true;
4605 }
4606 return res || verify_types_in_gimple_reference (rhs1, false);
4607
4608 /* tcc_constant */
4609 case SSA_NAME:
4610 case INTEGER_CST:
4611 case REAL_CST:
4612 case FIXED_CST:
4613 case COMPLEX_CST:
4614 case VECTOR_CST:
4615 case STRING_CST:
4616 return res;
4617
4618 /* tcc_declaration */
4619 case CONST_DECL:
4620 return res;
4621 case VAR_DECL:
4622 case PARM_DECL:
4623 if (!is_gimple_reg (lhs)
4624 && !is_gimple_reg (rhs1)
4625 && is_gimple_reg_type (TREE_TYPE (lhs)((contains_struct_check ((lhs), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4625, __FUNCTION__))->typed.type)
))
4626 {
4627 error ("invalid RHS for gimple memory store: %qs", code_name);
4628 debug_generic_stmt (lhs);
4629 debug_generic_stmt (rhs1);
4630 return true;
4631 }
4632 return res;
4633
4634 case CONSTRUCTOR:
4635 if (TREE_CODE (rhs1_type)((enum tree_code) (rhs1_type)->base.code) == VECTOR_TYPE)
4636 {
4637 unsigned int i;
4638 tree elt_i, elt_v, elt_t = NULL_TREE(tree) nullptr;
4639
4640 if (CONSTRUCTOR_NELTS (rhs1)(vec_safe_length (((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4640, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
== 0)
4641 return res;
4642 /* For vector CONSTRUCTORs we require that either it is empty
4643 CONSTRUCTOR, or it is a CONSTRUCTOR of smaller vector elements
4644 (then the element count must be correct to cover the whole
4645 outer vector and index must be NULL on all elements, or it is
4646 a CONSTRUCTOR of scalar elements, where we as an exception allow
4647 smaller number of elements (assuming zero filling) and
4648 consecutive indexes as compared to NULL indexes (such
4649 CONSTRUCTORs can appear in the IL from FEs). */
4650 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs1), i, elt_i, elt_v)for (i = 0; (i >= vec_safe_length (((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4650, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
? false : (((void) (elt_v = (*((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4650, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts))[
i].value)), (elt_i = (*((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4650, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts))[
i].index), true); (i)++)
4651 {
4652 if (elt_t == NULL_TREE(tree) nullptr)
4653 {
4654 elt_t = TREE_TYPE (elt_v)((contains_struct_check ((elt_v), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4654, __FUNCTION__))->typed.type)
;
4655 if (TREE_CODE (elt_t)((enum tree_code) (elt_t)->base.code) == VECTOR_TYPE)
4656 {
4657 tree elt_t = TREE_TYPE (elt_v)((contains_struct_check ((elt_v), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4657, __FUNCTION__))->typed.type)
;
4658 if (!useless_type_conversion_p (TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4658, __FUNCTION__))->typed.type)
,
4659 TREE_TYPE (elt_t)((contains_struct_check ((elt_t), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4659, __FUNCTION__))->typed.type)
))
4660 {
4661 error ("incorrect type of vector %qs elements",
4662 code_name);
4663 debug_generic_stmt (rhs1);
4664 return true;
4665 }
4666 else if (maybe_ne (CONSTRUCTOR_NELTS (rhs1)(vec_safe_length (((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4666, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
4667 * TYPE_VECTOR_SUBPARTS (elt_t),
4668 TYPE_VECTOR_SUBPARTS (rhs1_type)))
4669 {
4670 error ("incorrect number of vector %qs elements",
4671 code_name);
4672 debug_generic_stmt (rhs1);
4673 return true;
4674 }
4675 }
4676 else if (!useless_type_conversion_p (TREE_TYPE (rhs1_type)((contains_struct_check ((rhs1_type), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4676, __FUNCTION__))->typed.type)
,
4677 elt_t))
4678 {
4679 error ("incorrect type of vector %qs elements",
4680 code_name);
4681 debug_generic_stmt (rhs1);
4682 return true;
4683 }
4684 else if (maybe_gt (CONSTRUCTOR_NELTS (rhs1),maybe_lt (TYPE_VECTOR_SUBPARTS (rhs1_type), (vec_safe_length (
((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4684, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
)
4685 TYPE_VECTOR_SUBPARTS (rhs1_type))maybe_lt (TYPE_VECTOR_SUBPARTS (rhs1_type), (vec_safe_length (
((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4684, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
)
)
4686 {
4687 error ("incorrect number of vector %qs elements",
4688 code_name);
4689 debug_generic_stmt (rhs1);
4690 return true;
4691 }
4692 }
4693 else if (!useless_type_conversion_p (elt_t, TREE_TYPE (elt_v)((contains_struct_check ((elt_v), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4693, __FUNCTION__))->typed.type)
))
4694 {
4695 error ("incorrect type of vector CONSTRUCTOR elements");
4696 debug_generic_stmt (rhs1);
4697 return true;
4698 }
4699 if (elt_i != NULL_TREE(tree) nullptr
4700 && (TREE_CODE (elt_t)((enum tree_code) (elt_t)->base.code) == VECTOR_TYPE
4701 || TREE_CODE (elt_i)((enum tree_code) (elt_i)->base.code) != INTEGER_CST
4702 || compare_tree_int (elt_i, i) != 0))
4703 {
4704 error ("vector %qs with non-NULL element index",
4705 code_name);
4706 debug_generic_stmt (rhs1);
4707 return true;
4708 }
4709 if (!is_gimple_val (elt_v))
4710 {
4711 error ("vector %qs element is not a GIMPLE value",
4712 code_name);
4713 debug_generic_stmt (rhs1);
4714 return true;
4715 }
4716 }
4717 }
4718 else if (CONSTRUCTOR_NELTS (rhs1)(vec_safe_length (((tree_check ((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4718, __FUNCTION__, (CONSTRUCTOR)))->constructor.elts)))
!= 0)
4719 {
4720 error ("non-vector %qs with elements", code_name);
4721 debug_generic_stmt (rhs1);
4722 return true;
4723 }
4724 return res;
4725
4726 case ASSERT_EXPR:
4727 /* FIXME. */
4728 rhs1 = fold (ASSERT_EXPR_COND (rhs1)(*((const_cast<tree*> (tree_operand_check (((tree_check
((rhs1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4728, __FUNCTION__, (ASSERT_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4728, __FUNCTION__)))))
);
4729 if (rhs1 == boolean_false_nodeglobal_trees[TI_BOOLEAN_FALSE])
4730 {
4731 error ("%qs with an always-false condition", code_name);
4732 debug_generic_stmt (rhs1);
4733 return true;
4734 }
4735 break;
4736
4737 case WITH_SIZE_EXPR:
4738 error ("%qs RHS in assignment statement",
4739 get_tree_code_name (rhs_code));
4740 debug_generic_expr (rhs1);
4741 return true;
4742
4743 case OBJ_TYPE_REF:
4744 /* FIXME. */
4745 return res;
4746
4747 default:;
4748 }
4749
4750 return res;
4751}
4752
4753/* Verify the contents of a GIMPLE_ASSIGN STMT. Returns true when there
4754 is a problem, otherwise false. */
4755
4756static bool
4757verify_gimple_assign (gassign *stmt)
4758{
4759 switch (gimple_assign_rhs_class (stmt))
4760 {
4761 case GIMPLE_SINGLE_RHS:
4762 return verify_gimple_assign_single (stmt);
4763
4764 case GIMPLE_UNARY_RHS:
4765 return verify_gimple_assign_unary (stmt);
4766
4767 case GIMPLE_BINARY_RHS:
4768 return verify_gimple_assign_binary (stmt);
4769
4770 case GIMPLE_TERNARY_RHS:
4771 return verify_gimple_assign_ternary (stmt);
4772
4773 default:
4774 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4774, __FUNCTION__))
;
4775 }
4776}
4777
4778/* Verify the contents of a GIMPLE_RETURN STMT. Returns true when there
4779 is a problem, otherwise false. */
4780
4781static bool
4782verify_gimple_return (greturn *stmt)
4783{
4784 tree op = gimple_return_retval (stmt);
4785 tree restype = TREE_TYPE (TREE_TYPE (cfun->decl))((contains_struct_check ((((contains_struct_check (((cfun + 0
)->decl), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4785, __FUNCTION__))->typed.type)), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4785, __FUNCTION__))->typed.type)
;
4786
4787 /* We cannot test for present return values as we do not fix up missing
4788 return values from the original source. */
4789 if (op == NULLnullptr)
4790 return false;
4791
4792 if (!is_gimple_val (op)
4793 && TREE_CODE (op)((enum tree_code) (op)->base.code) != RESULT_DECL)
4794 {
4795 error ("invalid operand in return statement");
4796 debug_generic_stmt (op);
4797 return true;
4798 }
4799
4800 if ((TREE_CODE (op)((enum tree_code) (op)->base.code) == RESULT_DECL
4801 && DECL_BY_REFERENCE (op)((tree_check3 ((op), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4801, __FUNCTION__, (VAR_DECL), (PARM_DECL), (RESULT_DECL))
)->decl_common.decl_by_reference_flag)
)
4802 || (TREE_CODE (op)((enum tree_code) (op)->base.code) == SSA_NAME
4803 && SSA_NAME_VAR (op)((tree_check ((op), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4803, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((op)->ssa_name.var)->base
.code) == IDENTIFIER_NODE ? (tree) nullptr : (op)->ssa_name
.var)
4804 && TREE_CODE (SSA_NAME_VAR (op))((enum tree_code) (((tree_check ((op), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4804, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((op)->ssa_name.var)->base
.code) == IDENTIFIER_NODE ? (tree) nullptr : (op)->ssa_name
.var))->base.code)
== RESULT_DECL
4805 && DECL_BY_REFERENCE (SSA_NAME_VAR (op))((tree_check3 ((((tree_check ((op), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4805, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((op)->ssa_name.var)->base
.code) == IDENTIFIER_NODE ? (tree) nullptr : (op)->ssa_name
.var)), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4805, __FUNCTION__, (VAR_DECL), (PARM_DECL), (RESULT_DECL))
)->decl_common.decl_by_reference_flag)
))
4806 op = TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4806, __FUNCTION__))->typed.type)
;
4807
4808 if (!useless_type_conversion_p (restype, TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4808, __FUNCTION__))->typed.type)
))
4809 {
4810 error ("invalid conversion in return statement");
4811 debug_generic_stmt (restype);
4812 debug_generic_stmt (TREE_TYPE (op)((contains_struct_check ((op), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4812, __FUNCTION__))->typed.type)
);
4813 return true;
4814 }
4815
4816 return false;
4817}
4818
4819
4820/* Verify the contents of a GIMPLE_GOTO STMT. Returns true when there
4821 is a problem, otherwise false. */
4822
4823static bool
4824verify_gimple_goto (ggoto *stmt)
4825{
4826 tree dest = gimple_goto_dest (stmt);
4827
4828 /* ??? We have two canonical forms of direct goto destinations, a
4829 bare LABEL_DECL and an ADDR_EXPR of a LABEL_DECL. */
4830 if (TREE_CODE (dest)((enum tree_code) (dest)->base.code) != LABEL_DECL
4831 && (!is_gimple_val (dest)
4832 || !POINTER_TYPE_P (TREE_TYPE (dest))(((enum tree_code) (((contains_struct_check ((dest), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4832, __FUNCTION__))->typed.type))->base.code) == POINTER_TYPE
|| ((enum tree_code) (((contains_struct_check ((dest), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4832, __FUNCTION__))->typed.type))->base.code) == REFERENCE_TYPE
)
))
4833 {
4834 error ("goto destination is neither a label nor a pointer");
4835 return true;
4836 }
4837
4838 return false;
4839}
4840
4841/* Verify the contents of a GIMPLE_SWITCH STMT. Returns true when there
4842 is a problem, otherwise false. */
4843
4844static bool
4845verify_gimple_switch (gswitch *stmt)
4846{
4847 unsigned int i, n;
4848 tree elt, prev_upper_bound = NULL_TREE(tree) nullptr;
4849 tree index_type, elt_type = NULL_TREE(tree) nullptr;
4850
4851 if (!is_gimple_val (gimple_switch_index (stmt)))
4852 {
4853 error ("invalid operand to switch statement");
4854 debug_generic_stmt (gimple_switch_index (stmt));
4855 return true;
4856 }
4857
4858 index_type = TREE_TYPE (gimple_switch_index (stmt))((contains_struct_check ((gimple_switch_index (stmt)), (TS_TYPED
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4858, __FUNCTION__))->typed.type)
;
4859 if (! INTEGRAL_TYPE_P (index_type)(((enum tree_code) (index_type)->base.code) == ENUMERAL_TYPE
|| ((enum tree_code) (index_type)->base.code) == BOOLEAN_TYPE
|| ((enum tree_code) (index_type)->base.code) == INTEGER_TYPE
)
)
4860 {
4861 error ("non-integral type switch statement");
4862 debug_generic_expr (index_type);
4863 return true;
4864 }
4865
4866 elt = gimple_switch_label (stmt, 0);
4867 if (CASE_LOW (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4867, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4867, __FUNCTION__)))))
!= NULL_TREE(tree) nullptr
4868 || CASE_HIGH (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4868, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4868, __FUNCTION__)))))
!= NULL_TREE(tree) nullptr
4869 || CASE_CHAIN (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4869, __FUNCTION__, (CASE_LABEL_EXPR)))), (3), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4869, __FUNCTION__)))))
!= NULL_TREE(tree) nullptr)
4870 {
4871 error ("invalid default case label in switch statement");
4872 debug_generic_expr (elt);
4873 return true;
4874 }
4875
4876 n = gimple_switch_num_labels (stmt);
4877 for (i = 1; i < n; i++)
4878 {
4879 elt = gimple_switch_label (stmt, i);
4880
4881 if (CASE_CHAIN (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4881, __FUNCTION__, (CASE_LABEL_EXPR)))), (3), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4881, __FUNCTION__)))))
)
4882 {
4883 error ("invalid %<CASE_CHAIN%>");
4884 debug_generic_expr (elt);
4885 return true;
4886 }
4887 if (! CASE_LOW (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4887, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4887, __FUNCTION__)))))
)
4888 {
4889 error ("invalid case label in switch statement");
4890 debug_generic_expr (elt);
4891 return true;
4892 }
4893 if (CASE_HIGH (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4893, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4893, __FUNCTION__)))))
4894 && ! tree_int_cst_lt (CASE_LOW (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4894, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4894, __FUNCTION__)))))
, CASE_HIGH (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4894, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4894, __FUNCTION__)))))
))
4895 {
4896 error ("invalid case range in switch statement");
4897 debug_generic_expr (elt);
4898 return true;
4899 }
4900
4901 if (! elt_type)
4902 {
4903 elt_type = TREE_TYPE (CASE_LOW (elt))((contains_struct_check (((*((const_cast<tree*> (tree_operand_check
(((tree_check ((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4903, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4903, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4903, __FUNCTION__))->typed.type)
;
4904 if (TYPE_PRECISION (index_type)((tree_class_check ((index_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4904, __FUNCTION__))->type_common.precision)
< TYPE_PRECISION (elt_type)((tree_class_check ((elt_type), (tcc_type), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4904, __FUNCTION__))->type_common.precision)
)
4905 {
4906 error ("type precision mismatch in switch statement");
4907 return true;
4908 }
4909 }
4910 if (TREE_TYPE (CASE_LOW (elt))((contains_struct_check (((*((const_cast<tree*> (tree_operand_check
(((tree_check ((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4910, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4910, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4910, __FUNCTION__))->typed.type)
!= elt_type
4911 || (CASE_HIGH (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4911, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4911, __FUNCTION__)))))
&& TREE_TYPE (CASE_HIGH (elt))((contains_struct_check (((*((const_cast<tree*> (tree_operand_check
(((tree_check ((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4911, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4911, __FUNCTION__)))))), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4911, __FUNCTION__))->typed.type)
!= elt_type))
4912 {
4913 error ("type mismatch for case label in switch statement");
4914 debug_generic_expr (elt);
4915 return true;
4916 }
4917
4918 if (prev_upper_bound)
4919 {
4920 if (! tree_int_cst_lt (prev_upper_bound, CASE_LOW (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4920, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4920, __FUNCTION__)))))
))
4921 {
4922 error ("case labels not sorted in switch statement");
4923 return true;
4924 }
4925 }
4926
4927 prev_upper_bound = CASE_HIGH (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4927, __FUNCTION__, (CASE_LABEL_EXPR)))), (1), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4927, __FUNCTION__)))))
;
4928 if (! prev_upper_bound)
4929 prev_upper_bound = CASE_LOW (elt)(*((const_cast<tree*> (tree_operand_check (((tree_check
((elt), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4929, __FUNCTION__, (CASE_LABEL_EXPR)))), (0), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4929, __FUNCTION__)))))
;
4930 }
4931
4932 return false;
4933}
4934
4935/* Verify a gimple debug statement STMT.
4936 Returns true if anything is wrong. */
4937
4938static bool
4939verify_gimple_debug (gimple *stmt ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
4940{
4941 /* There isn't much that could be wrong in a gimple debug stmt. A
4942 gimple debug bind stmt, for example, maps a tree, that's usually
4943 a VAR_DECL or a PARM_DECL, but that could also be some scalarized
4944 component or member of an aggregate type, to another tree, that
4945 can be an arbitrary expression. These stmts expand into debug
4946 insns, and are converted to debug notes by var-tracking.c. */
4947 return false;
4948}
4949
4950/* Verify a gimple label statement STMT.
4951 Returns true if anything is wrong. */
4952
4953static bool
4954verify_gimple_label (glabel *stmt)
4955{
4956 tree decl = gimple_label_label (stmt);
4957 int uid;
4958 bool err = false;
4959
4960 if (TREE_CODE (decl)((enum tree_code) (decl)->base.code) != LABEL_DECL)
4961 return true;
4962 if (!DECL_NONLOCAL (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4962, __FUNCTION__))->decl_common.nonlocal_flag)
&& !FORCED_LABEL (decl)((tree_check ((decl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4962, __FUNCTION__, (LABEL_DECL)))->base.side_effects_flag
)
4963 && DECL_CONTEXT (decl)((contains_struct_check ((decl), (TS_DECL_MINIMAL), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4963, __FUNCTION__))->decl_minimal.context)
!= current_function_decl)
4964 {
4965 error ("label context is not the current function declaration");
4966 err |= true;
4967 }
4968
4969 uid = LABEL_DECL_UID (decl)((tree_check ((decl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4969, __FUNCTION__, (LABEL_DECL)))->label_decl.label_decl_uid
)
;
4970 if (cfun(cfun + 0)->cfg
4971 && (uid == -1
4972 || (*label_to_block_map_for_fn (cfun)(((cfun + 0))->cfg->x_label_to_block_map))[uid] != gimple_bb (stmt)))
4973 {
4974 error ("incorrect entry in %<label_to_block_map%>");
4975 err |= true;
4976 }
4977
4978 uid = EH_LANDING_PAD_NR (decl)((tree_check ((decl), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 4978, __FUNCTION__, (LABEL_DECL)))->label_decl.eh_landing_pad_nr
)
;
4979 if (uid)
4980 {
4981 eh_landing_pad lp = get_eh_landing_pad_from_number (uid);
4982 if (decl != lp->post_landing_pad)
4983 {
4984 error ("incorrect setting of landing pad number");
4985 err |= true;
4986 }
4987 }
4988
4989 return err;
4990}
4991
4992/* Verify a gimple cond statement STMT.
4993 Returns true if anything is wrong. */
4994
4995static bool
4996verify_gimple_cond (gcond *stmt)
4997{
4998 if (TREE_CODE_CLASS (gimple_cond_code (stmt))tree_code_type[(int) (gimple_cond_code (stmt))] != tcc_comparison)
4999 {
5000 error ("invalid comparison code in gimple cond");
5001 return true;
5002 }
5003 if (!(!gimple_cond_true_label (stmt)
5004 || TREE_CODE (gimple_cond_true_label (stmt))((enum tree_code) (gimple_cond_true_label (stmt))->base.code
)
== LABEL_DECL)
5005 || !(!gimple_cond_false_label (stmt)
5006 || TREE_CODE (gimple_cond_false_label (stmt))((enum tree_code) (gimple_cond_false_label (stmt))->base.code
)
== LABEL_DECL))
5007 {
5008 error ("invalid labels in gimple cond");
5009 return true;
5010 }
5011
5012 return verify_gimple_comparison (boolean_type_nodeglobal_trees[TI_BOOLEAN_TYPE],
5013 gimple_cond_lhs (stmt),
5014 gimple_cond_rhs (stmt),
5015 gimple_cond_code (stmt));
5016}
5017
5018/* Verify the GIMPLE statement STMT. Returns true if there is an
5019 error, otherwise false. */
5020
5021static bool
5022verify_gimple_stmt (gimple *stmt)
5023{
5024 switch (gimple_code (stmt))
5025 {
5026 case GIMPLE_ASSIGN:
5027 return verify_gimple_assign (as_a <gassign *> (stmt));
5028
5029 case GIMPLE_LABEL:
5030 return verify_gimple_label (as_a <glabel *> (stmt));
5031
5032 case GIMPLE_CALL:
5033 return verify_gimple_call (as_a <gcall *> (stmt));
5034
5035 case GIMPLE_COND:
5036 return verify_gimple_cond (as_a <gcond *> (stmt));
5037
5038 case GIMPLE_GOTO:
5039 return verify_gimple_goto (as_a <ggoto *> (stmt));
5040
5041 case GIMPLE_SWITCH:
5042 return verify_gimple_switch (as_a <gswitch *> (stmt));
5043
5044 case GIMPLE_RETURN:
5045 return verify_gimple_return (as_a <greturn *> (stmt));
5046
5047 case GIMPLE_ASM:
5048 return false;
5049
5050 case GIMPLE_TRANSACTION:
5051 return verify_gimple_transaction (as_a <gtransaction *> (stmt));
5052
5053 /* Tuples that do not have tree operands. */
5054 case GIMPLE_NOP:
5055 case GIMPLE_PREDICT:
5056 case GIMPLE_RESX:
5057 case GIMPLE_EH_DISPATCH:
5058 case GIMPLE_EH_MUST_NOT_THROW:
5059 return false;
5060
5061 CASE_GIMPLE_OMPcase GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: case GIMPLE_OMP_FOR
: case GIMPLE_OMP_SECTIONS: case GIMPLE_OMP_SECTIONS_SWITCH: case
GIMPLE_OMP_SINGLE: case GIMPLE_OMP_TARGET: case GIMPLE_OMP_TEAMS
: case GIMPLE_OMP_SCOPE: case GIMPLE_OMP_SECTION: case GIMPLE_OMP_MASTER
: case GIMPLE_OMP_MASKED: case GIMPLE_OMP_TASKGROUP: case GIMPLE_OMP_ORDERED
: case GIMPLE_OMP_CRITICAL: case GIMPLE_OMP_SCAN: case GIMPLE_OMP_RETURN
: case GIMPLE_OMP_ATOMIC_LOAD: case GIMPLE_OMP_ATOMIC_STORE: case
GIMPLE_OMP_CONTINUE
:
5062 /* OpenMP directives are validated by the FE and never operated
5063 on by the optimizers. Furthermore, GIMPLE_OMP_FOR may contain
5064 non-gimple expressions when the main index variable has had
5065 its address taken. This does not affect the loop itself
5066 because the header of an GIMPLE_OMP_FOR is merely used to determine
5067 how to setup the parallel iteration. */
5068 return false;
5069
5070 case GIMPLE_DEBUG:
5071 return verify_gimple_debug (stmt);
5072
5073 default:
5074 gcc_unreachable ()(fancy_abort ("/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5074, __FUNCTION__))
;
5075 }
5076}
5077
5078/* Verify the contents of a GIMPLE_PHI. Returns true if there is a problem,
5079 and false otherwise. */
5080
5081static bool
5082verify_gimple_phi (gphi *phi)
5083{
5084 bool err = false;
5085 unsigned i;
5086 tree phi_result = gimple_phi_result (phi);
5087 bool virtual_p;
5088
5089 if (!phi_result)
5090 {
5091 error ("invalid %<PHI%> result");
5092 return true;
5093 }
5094
5095 virtual_p = virtual_operand_p (phi_result);
5096 if (TREE_CODE (phi_result)((enum tree_code) (phi_result)->base.code) != SSA_NAME
5097 || (virtual_p
5098 && SSA_NAME_VAR (phi_result)((tree_check ((phi_result), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5098, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((phi_result)->ssa_name.var)
->base.code) == IDENTIFIER_NODE ? (tree) nullptr : (phi_result
)->ssa_name.var)
!= gimple_vop (cfun(cfun + 0))))
5099 {
5100 error ("invalid %<PHI%> result");
5101 err = true;
5102 }
5103
5104 for (i = 0; i < gimple_phi_num_args (phi); i++)
5105 {
5106 tree t = gimple_phi_arg_def (phi, i);
5107
5108 if (!t)
5109 {
5110 error ("missing %<PHI%> def");
5111 err |= true;
5112 continue;
5113 }
5114 /* Addressable variables do have SSA_NAMEs but they
5115 are not considered gimple values. */
5116 else if ((TREE_CODE (t)((enum tree_code) (t)->base.code) == SSA_NAME
5117 && virtual_p != virtual_operand_p (t))
5118 || (virtual_p
5119 && (TREE_CODE (t)((enum tree_code) (t)->base.code) != SSA_NAME
5120 || SSA_NAME_VAR (t)((tree_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5120, __FUNCTION__, (SSA_NAME)))->ssa_name.var == (tree)
nullptr || ((enum tree_code) ((t)->ssa_name.var)->base
.code) == IDENTIFIER_NODE ? (tree) nullptr : (t)->ssa_name
.var)
!= gimple_vop (cfun(cfun + 0))))
5121 || (!virtual_p
5122 && !is_gimple_val (t)))
5123 {
5124 error ("invalid %<PHI%> argument");
5125 debug_generic_expr (t);
5126 err |= true;
5127 }
5128#ifdef ENABLE_TYPES_CHECKING1
5129 if (!useless_type_conversion_p (TREE_TYPE (phi_result)((contains_struct_check ((phi_result), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5129, __FUNCTION__))->typed.type)
, TREE_TYPE (t)((contains_struct_check ((t), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5129, __FUNCTION__))->typed.type)
))
5130 {
5131 error ("incompatible types in %<PHI%> argument %u", i);
5132 debug_generic_stmt (TREE_TYPE (phi_result)((contains_struct_check ((phi_result), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5132, __FUNCTION__))->typed.type)
);
5133 debug_generic_stmt (TREE_TYPE (t)((contains_struct_check ((t), (TS_TYPED), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5133, __FUNCTION__))->typed.type)
);
5134 err |= true;
5135 }
5136#endif
5137 }
5138
5139 return err;
5140}
5141
5142/* Verify the GIMPLE statements inside the sequence STMTS. */
5143
5144static bool
5145verify_gimple_in_seq_2 (gimple_seq stmts)
5146{
5147 gimple_stmt_iterator ittr;
5148 bool err = false;
5149
5150 for (ittr = gsi_start (stmts)gsi_start_1 (&(stmts)); !gsi_end_p (ittr); gsi_next (&ittr))
5151 {
5152 gimple *stmt = gsi_stmt (ittr);
5153
5154 switch (gimple_code (stmt))
5155 {
5156 case GIMPLE_BIND:
5157 err |= verify_gimple_in_seq_2 (
5158 gimple_bind_body (as_a <gbind *> (stmt)));
5159 break;
5160
5161 case GIMPLE_TRY:
5162 err |= verify_gimple_in_seq_2 (gimple_try_eval (stmt));
5163 err |= verify_gimple_in_seq_2 (gimple_try_cleanup (stmt));
5164 break;
5165
5166 case GIMPLE_EH_FILTER:
5167 err |= verify_gimple_in_seq_2 (gimple_eh_filter_failure (stmt));
5168 break;
5169
5170 case GIMPLE_EH_ELSE:
5171 {
5172 geh_else *eh_else = as_a <geh_else *> (stmt);
5173 err |= verify_gimple_in_seq_2 (gimple_eh_else_n_body (eh_else));
5174 err |= verify_gimple_in_seq_2 (gimple_eh_else_e_body (eh_else));
5175 }
5176 break;
5177
5178 case GIMPLE_CATCH:
5179 err |= verify_gimple_in_seq_2 (gimple_catch_handler (
5180 as_a <gcatch *> (stmt)));
5181 break;
5182
5183 case GIMPLE_TRANSACTION:
5184 err |= verify_gimple_transaction (as_a <gtransaction *> (stmt));
5185 break;
5186
5187 default:
5188 {
5189 bool err2 = verify_gimple_stmt (stmt);
5190 if (err2)
5191 debug_gimple_stmt (stmt);
5192 err |= err2;
5193 }
5194 }
5195 }
5196
5197 return err;
5198}
5199
5200/* Verify the contents of a GIMPLE_TRANSACTION. Returns true if there
5201 is a problem, otherwise false. */
5202
5203static bool
5204verify_gimple_transaction (gtransaction *stmt)
5205{
5206 tree lab;
5207
5208 lab = gimple_transaction_label_norm (stmt);
5209 if (lab != NULLnullptr && TREE_CODE (lab)((enum tree_code) (lab)->base.code) != LABEL_DECL)
5210 return true;
5211 lab = gimple_transaction_label_uninst (stmt);
5212 if (lab != NULLnullptr && TREE_CODE (lab)((enum tree_code) (lab)->base.code) != LABEL_DECL)
5213 return true;
5214 lab = gimple_transaction_label_over (stmt);
5215 if (lab != NULLnullptr && TREE_CODE (lab)((enum tree_code) (lab)->base.code) != LABEL_DECL)
5216 return true;
5217
5218 return verify_gimple_in_seq_2 (gimple_transaction_body (stmt));
5219}
5220
5221
5222/* Verify the GIMPLE statements inside the statement list STMTS. */
5223
5224DEBUG_FUNCTION__attribute__ ((__used__)) void
5225verify_gimple_in_seq (gimple_seq stmts)
5226{
5227 timevar_push (TV_TREE_STMT_VERIFY);
5228 if (verify_gimple_in_seq_2 (stmts))
5229 internal_error ("%<verify_gimple%> failed");
5230 timevar_pop (TV_TREE_STMT_VERIFY);
5231}
5232
5233/* Return true when the T can be shared. */
5234
5235static bool
5236tree_node_can_be_shared (tree t)
5237{
5238 if (IS_TYPE_OR_DECL_P (t)((tree_code_type[(int) (((enum tree_code) (t)->base.code))
] == tcc_type) || (tree_code_type[(int) (((enum tree_code) (t
)->base.code))] == tcc_declaration))
5239 || TREE_CODE (t)((enum tree_code) (t)->base.code) == SSA_NAME
5240 || TREE_CODE (t)((enum tree_code) (t)->base.code) == IDENTIFIER_NODE
5241 || TREE_CODE (t)((enum tree_code) (t)->base.code) == CASE_LABEL_EXPR
5242 || is_gimple_min_invariant (t))
5243 return true;
5244
5245 if (t == error_mark_nodeglobal_trees[TI_ERROR_MARK])
5246 return true;
5247
5248 return false;
5249}
5250
5251/* Called via walk_tree. Verify tree sharing. */
5252
5253static tree
5254verify_node_sharing_1 (tree *tp, int *walk_subtrees, void *data)
5255{
5256 hash_set<void *> *visited = (hash_set<void *> *) data;
5257
5258 if (tree_node_can_be_shared (*tp))
5259 {
5260 *walk_subtrees = false;
5261 return NULLnullptr;
5262 }
5263
5264 if (visited->add (*tp))
5265 return *tp;
5266
5267 return NULLnullptr;
5268}
5269
5270/* Called via walk_gimple_stmt. Verify tree sharing. */
5271
5272static tree
5273verify_node_sharing (tree *tp, int *walk_subtrees, void *data)
5274{
5275 struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
5276 return verify_node_sharing_1 (tp, walk_subtrees, wi->info);
5277}
5278
5279static bool eh_error_found;
5280bool
5281verify_eh_throw_stmt_node (gimple *const &stmt, const int &,
5282 hash_set<gimple *> *visited)
5283{
5284 if (!visited->contains (stmt))
5285 {
5286 error ("dead statement in EH table");
5287 debug_gimple_stmt (stmt);
5288 eh_error_found = true;
5289 }
5290 return true;
5291}
5292
5293/* Verify if the location LOCs block is in BLOCKS. */
5294
5295static bool
5296verify_location (hash_set<tree> *blocks, location_t loc)
5297{
5298 tree block = LOCATION_BLOCK (loc)((tree) ((IS_ADHOC_LOC (loc)) ? get_data_from_adhoc_loc (line_table
, (loc)) : nullptr))
;
5299 if (block != NULL_TREE(tree) nullptr
5300 && !blocks->contains (block))
5301 {
5302 error ("location references block not in block tree");
5303 return true;
5304 }
5305 if (block != NULL_TREE(tree) nullptr)
5306 return verify_location (blocks, BLOCK_SOURCE_LOCATION (block)((tree_check ((block), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5306, __FUNCTION__, (BLOCK)))->block.locus)
);
5307 return false;
5308}
5309
5310/* Called via walk_tree. Verify that expressions have no blocks. */
5311
5312static tree
5313verify_expr_no_block (tree *tp, int *walk_subtrees, void *)
5314{
5315 if (!EXPR_P (*tp)((tree_code_type[(int) (((enum tree_code) (*tp)->base.code
))]) >= tcc_reference && (tree_code_type[(int) (((
enum tree_code) (*tp)->base.code))]) <= tcc_expression)
)
5316 {
5317 *walk_subtrees = false;
5318 return NULLnullptr;
5319 }
5320
5321 location_t loc = EXPR_LOCATION (*tp)((((*tp)) && ((tree_code_type[(int) (((enum tree_code
) ((*tp))->base.code))]) >= tcc_reference && (tree_code_type
[(int) (((enum tree_code) ((*tp))->base.code))]) <= tcc_expression
)) ? (*tp)->exp.locus : ((location_t) 0))
;
5322 if (LOCATION_BLOCK (loc)((tree) ((IS_ADHOC_LOC (loc)) ? get_data_from_adhoc_loc (line_table
, (loc)) : nullptr))
!= NULLnullptr)
5323 return *tp;
5324
5325 return NULLnullptr;
5326}
5327
5328/* Called via walk_tree. Verify locations of expressions. */
5329
5330static tree
5331verify_expr_location_1 (tree *tp, int *walk_subtrees, void *data)
5332{
5333 hash_set<tree> *blocks = (hash_set<tree> *) data;
5334 tree t = *tp;
5335
5336 /* ??? This doesn't really belong here but there's no good place to
5337 stick this remainder of old verify_expr. */
5338 /* ??? This barfs on debug stmts which contain binds to vars with
5339 different function context. */
5340#if 0
5341 if (VAR_P (t)(((enum tree_code) (t)->base.code) == VAR_DECL)
5342 || TREE_CODE (t)((enum tree_code) (t)->base.code) == PARM_DECL
5343 || TREE_CODE (t)((enum tree_code) (t)->base.code) == RESULT_DECL)
5344 {
5345 tree context = decl_function_context (t);
5346 if (context != cfun(cfun + 0)->decl
5347 && !SCOPE_FILE_SCOPE_P (context)(! (context) || ((enum tree_code) (context)->base.code) ==
TRANSLATION_UNIT_DECL)
5348 && !TREE_STATIC (t)((t)->base.static_flag)
5349 && !DECL_EXTERNAL (t)((contains_struct_check ((t), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5349, __FUNCTION__))->decl_common.decl_flag_1)
)
5350 {
5351 error ("local declaration from a different function");
5352 return t;
5353 }
5354 }
5355#endif
5356
5357 if (VAR_P (t)(((enum tree_code) (t)->base.code) == VAR_DECL) && DECL_HAS_DEBUG_EXPR_P (t)((tree_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5357, __FUNCTION__, (VAR_DECL)))->decl_common.debug_expr_is_from
)
)
5358 {
5359 tree x = DECL_DEBUG_EXPR (t)(decl_debug_expr_lookup ((tree_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5359, __FUNCTION__, (VAR_DECL)))))
;
5360 tree addr = walk_tree (&x, verify_expr_no_block, NULL, NULL)walk_tree_1 (&x, verify_expr_no_block, nullptr, nullptr, nullptr
)
;
5361 if (addr)
5362 return addr;
5363 }
5364 if ((VAR_P (t)(((enum tree_code) (t)->base.code) == VAR_DECL)
5365 || TREE_CODE (t)((enum tree_code) (t)->base.code) == PARM_DECL
5366 || TREE_CODE (t)((enum tree_code) (t)->base.code) == RESULT_DECL)
5367 && DECL_HAS_VALUE_EXPR_P (t)((tree_check3 ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5367, __FUNCTION__, (VAR_DECL), (PARM_DECL), (RESULT_DECL))
) ->decl_common.decl_flag_2)
)
5368 {
5369 tree x = DECL_VALUE_EXPR (t)(decl_value_expr_lookup ((contains_struct_check ((t), (TS_DECL_WRTL
), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5369, __FUNCTION__))))
;
5370 tree addr = walk_tree (&x, verify_expr_no_block, NULL, NULL)walk_tree_1 (&x, verify_expr_no_block, nullptr, nullptr, nullptr
)
;
5371 if (addr)
5372 return addr;
5373 }
5374
5375 if (!EXPR_P (t)((tree_code_type[(int) (((enum tree_code) (t)->base.code))
]) >= tcc_reference && (tree_code_type[(int) (((enum
tree_code) (t)->base.code))]) <= tcc_expression)
)
5376 {
5377 *walk_subtrees = false;
5378 return NULLnullptr;
5379 }
5380
5381 location_t loc = EXPR_LOCATION (t)((((t)) && ((tree_code_type[(int) (((enum tree_code) (
(t))->base.code))]) >= tcc_reference && (tree_code_type
[(int) (((enum tree_code) ((t))->base.code))]) <= tcc_expression
)) ? (t)->exp.locus : ((location_t) 0))
;
5382 if (verify_location (blocks, loc))
5383 return t;
5384
5385 return NULLnullptr;
5386}
5387
5388/* Called via walk_gimple_op. Verify locations of expressions. */
5389
5390static tree
5391verify_expr_location (tree *tp, int *walk_subtrees, void *data)
5392{
5393 struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
5394 return verify_expr_location_1 (tp, walk_subtrees, wi->info);
5395}
5396
5397/* Insert all subblocks of BLOCK into BLOCKS and recurse. */
5398
5399static void
5400collect_subblocks (hash_set<tree> *blocks, tree block)
5401{
5402 tree t;
5403 for (t = BLOCK_SUBBLOCKS (block)((tree_check ((block), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5403, __FUNCTION__, (BLOCK)))->block.subblocks)
; t; t = BLOCK_CHAIN (t)((tree_check ((t), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5403, __FUNCTION__, (BLOCK)))->block.chain)
)
5404 {
5405 blocks->add (t);
5406 collect_subblocks (blocks, t);
5407 }
5408}
5409
5410/* Disable warnings about missing quoting in GCC diagnostics for
5411 the verification errors. Their format strings don't follow
5412 GCC diagnostic conventions and trigger an ICE in the end. */
5413#if __GNUC__4 >= 10
5414# pragma GCC diagnostic push
5415# pragma GCC diagnostic ignored "-Wformat-diag"
5416#endif
5417
5418/* Verify the GIMPLE statements in the CFG of FN. */
5419
5420DEBUG_FUNCTION__attribute__ ((__used__)) void
5421verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
5422{
5423 basic_block bb;
5424 bool err = false;
5425
5426 timevar_push (TV_TREE_STMT_VERIFY);
5427 hash_set<void *> visited;
5428 hash_set<gimple *> visited_throwing_stmts;
5429
5430 /* Collect all BLOCKs referenced by the BLOCK tree of FN. */
5431 hash_set<tree> blocks;
5432 if (DECL_INITIAL (fn->decl)((contains_struct_check ((fn->decl), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5432, __FUNCTION__))->decl_common.initial)
)
5433 {
5434 blocks.add (DECL_INITIAL (fn->decl)((contains_struct_check ((fn->decl), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5434, __FUNCTION__))->decl_common.initial)
);
5435 collect_subblocks (&blocks, DECL_INITIAL (fn->decl)((contains_struct_check ((fn->decl), (TS_DECL_COMMON), "/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/tree-cfg.c"
, 5435, __FUNCTION__))->decl_common.initial)
);
5436 }
5437
5438 FOR_EACH_BB_FN (bb, fn)for (bb = (fn)->cfg->x_entry_block_ptr->next_bb; bb !=
(fn)->cfg->x_exit_block_ptr; bb = bb->next_bb)
5439 {
5440 gimple_stmt_iterator gsi;
5441 edge_iterator ei;
5442 edge e;
5443
5444 for (gphi_iterator gpi = gsi_start_phis (bb);
5445 !gsi_end_p (gpi);
5446 gsi_next (&gpi))
5447 {
5448 gphi *phi = gpi.phi ();
5449 bool err2 = false;
5450 unsigned i;
5451
5452 if (gimple_bb (phi) != bb)
5453 {
5454 error ("gimple_bb (phi) is set to a wrong basic block");
5455 err2 = true;
5456 }
5457
5458 err2 |= verify_gimple_phi (phi);
5459
5460 /* Only PHI arguments have locations. */
5461 if (gimple_location (phi) != UNKNOWN_LOCATION((location_t) 0))
5462 {
5463 error ("PHI node with location");
5464 err2 = true;
5465 }
5466
5467 for (i = 0; i < gimple_phi_num_args (phi); i++)
5468 {
5469 tree arg = gimple_phi_arg_def (phi, i);
5470 tree addr = walk_tree (&arg, verify_node_sharing_1,walk_tree_1 (&arg, verify_node_sharing_1, &visited, nullptr
, nullptr)
5471 &visited, NULL)walk_tree_1 (&arg, verify_node_sharing_1, &visited, nullptr
, nullptr)
;
5472 if (addr)
5473 {
5474 error ("incorrect sharing of tree nodes");
5475 debug_generic_expr (addr);
5476 err2 |= true;
5477 }
5478 location_t loc = gimple_phi_arg_location (phi, i);
5479 if (virtual_operand_p (gimple_phi_result (phi))
5480 && loc != UNKNOWN_LOCATION((location_t) 0))
5481 {
5482 error ("virtual PHI with argument locations");
5483 err2 = true;
5484 }
5485 addr = walk_tree (&arg, verify_expr_location_1, &blocks, NULL)walk_tree_1 (&arg, verify_expr_location_1, &blocks, nullptr
, nullptr)
;
5486 if (addr)
5487 {
5488 debug_generic_expr (addr);
5489 err2 = true;
5490 }
5491 err2 |= verify_location (&blocks, loc);
5492 }
5493
5494 if (err2)
5495 debug_gimple_stmt (phi);
5496 err |= err2;
5497 }
5498
5499 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
5500 {
5501 gimple *stmt = gsi_stmt (gsi);
5502 bool err2 = false;
5503 struct walk_stmt_info wi;
5504 tree addr;
5505 int lp_nr;
5506
5507 if (gimple_bb (stmt) != bb)
5508 {
5509 error ("gimple_bb (stmt) is set to a wrong basic block");
5510 err2 = true;
5511 }
5512
5513 err2 |= verify_gimple_stmt (stmt);
5514 err2 |= verify_location (&blocks, gimple_location (stmt));
5515
5516 memset (&wi, 0, sizeof (wi));
5517 wi.info = (void *) &visited;
5518 addr = walk_gimple_op (stmt, verify_node_sharing, &wi);
5519 if (addr)
5520 {
5521 error ("incorrect sharing of tree nodes");
5522 debug_generic_expr (addr);
5523 err2 |= true;
5524 }
5525
5526 memset (&wi, 0, sizeof (wi));
5527 wi.info = (void *) &blocks;
5528 addr = walk_gimple_op (stmt, verify_expr_location, &wi);
5529 if (addr)
5530 {
5531 debug_generic_expr (addr);
5532 err2 |= true;
5533 }
5534
5535 /* If the statement is marked as part of an EH region, then it is
5536 expected that the statement could throw. Verify that when we
5537 have optimizations that simplify statements such that we prove
5538 that they cannot throw, that we update other data structures
5539 to match. */
5540 lp_nr = lookup_stmt_eh_lp (stmt);
5541 if (lp_nr != 0)
5542 visited_throwing_stmts.add (stmt);
5543 if (lp_nr > 0)
5544 {
5545 if (!stmt_could_throw_p (cfun(cfun + 0), stmt))
5546 {
5547 if (verify_nothrow)
5548 {
5549 error ("statement marked for throw, but doesn%'t");
5550 err2 |= true;
5551 }
5552 }
5553 else if (!gsi_one_before_end_p (gsi))
5554 {
5555 error ("statement marked for throw in middle of block");
5556 err2 |= true;
5557 }
5558 }
5559
5560 if (err2)
5561 debug_gimple_stmt (stmt);
5562 err |= err2;
5563 }
5564
5565 FOR_EACH_EDGE (e, ei, bb->succs)for ((ei) = ei_start_1 (&((bb->succs))); ei_cond ((ei)
, &(e)); ei_next (&(ei)))
5566 if (e->goto_locus != UNKNOWN_LOCATION((location_t) 0))
5567 err |= verify_location (&blocks, e->goto_locus);
5568 }
5569
5570 hash_map<gimple *, int> *eh_table = get_eh_throw_stmt_table (cfun(cfun + 0));
5571 eh_error_found = false;
5572 if (eh_table)
5573 eh_table->traverse<hash_set<gimple *> *, verify_eh_throw_stmt_node>
5574 (&visited_throwing_stmts);
5575
5576 if (err || eh_error_found)
5577 internal_error ("verify_gimple failed");
5578
5579 verify_histograms ();
5580 timevar_pop (TV_TREE_STMT_VERIFY);
5581}
5582
5583
5584/* Verifies that the flow information is OK. */
5585
5586static int
5587gimple_verify_flow_info (void)
5588{
5589 int err = 0;
5590 basic_block bb;
5591 gimple_stmt_iterator gsi;
5592 gimple *stmt;
5593 edge e;
5594 edge_iterator ei;
5595
5596 if (ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr)->il.gimple.seq
5597 || ENTRY_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_entry_block_ptr)->il.gimple.phi_nodes)
5598 {
5599 error ("ENTRY_BLOCK has IL associated with it");
5600 err = 1;
5601 }
5602
5603 if (EXIT_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_exit_block_ptr)->il.gimple.seq
5604 || EXIT_BLOCK_PTR_FOR_FN (cfun)(((cfun + 0))->cfg->x_exit_block_ptr)->il.gimple.phi_nodes)
5605 {
5606 error ("EXIT_BLOCK has IL associated with it");
5607 err = 1;
5608 }
5609
5610 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)for ((ei) = ei_start_1 (&(((((cfun + 0))->cfg->x_exit_block_ptr
)->preds))); ei_cond ((ei), &(e)); ei_next (&(ei))
)
5611 if (e->flags & EDGE_FALLTHRU)
5612 {
5613 error ("fallthru to exit from bb %d", e->src->index);
5614 err = 1;
5615 }
5616