comparison gcc/ipa-type-escape.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* Type based alias analysis. 1 /* Escape analysis for types.
2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, 2 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010
3 Inc. 3 Free Software Foundation, Inc.
4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> 4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
8 GCC is free software; you can redistribute it and/or modify it under 8 GCC is free software; you can redistribute it and/or modify it under
51 #include "cgraph.h" 51 #include "cgraph.h"
52 #include "output.h" 52 #include "output.h"
53 #include "flags.h" 53 #include "flags.h"
54 #include "timevar.h" 54 #include "timevar.h"
55 #include "diagnostic.h" 55 #include "diagnostic.h"
56 #include "tree-pretty-print.h"
56 #include "langhooks.h" 57 #include "langhooks.h"
57 58
58 /* Some of the aliasing is called very early, before this phase is 59 /* Some of the aliasing is called very early, before this phase is
59 called. To assure that this is not a problem, we keep track of if 60 called. To assure that this is not a problem, we keep track of if
60 this phase has been run. */ 61 this phase has been run. */
1070 /* If the variable has the "used" attribute, treat it as if it had a 1071 /* If the variable has the "used" attribute, treat it as if it had a
1071 been touched by the devil. */ 1072 been touched by the devil. */
1072 tree type = get_canon_type (TREE_TYPE (t), false, false); 1073 tree type = get_canon_type (TREE_TYPE (t), false, false);
1073 if (!type) return; 1074 if (!type) return;
1074 1075
1075 if (lookup_attribute ("used", DECL_ATTRIBUTES (t))) 1076 if (DECL_PRESERVE_P (t))
1076 { 1077 {
1077 mark_interesting_type (type, FULL_ESCAPE); 1078 mark_interesting_type (type, FULL_ESCAPE);
1078 return; 1079 return;
1079 } 1080 }
1080 1081
1338 /* Check that there are no implicit casts in the passing of 1339 /* Check that there are no implicit casts in the passing of
1339 parameters. */ 1340 parameters. */
1340 if (TYPE_ARG_TYPES (TREE_TYPE (callee_t))) 1341 if (TYPE_ARG_TYPES (TREE_TYPE (callee_t)))
1341 { 1342 {
1342 for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t)), i = 0; 1343 for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t)), i = 0;
1343 arg_type && TREE_VALUE (arg_type) != void_type_node; 1344 arg_type && TREE_VALUE (arg_type) != void_type_node
1345 && i < gimple_call_num_args (call);
1344 arg_type = TREE_CHAIN (arg_type), i++) 1346 arg_type = TREE_CHAIN (arg_type), i++)
1345 { 1347 {
1346 tree operand = gimple_call_arg (call, i); 1348 tree operand = gimple_call_arg (call, i);
1347 if (operand) 1349 if (operand)
1348 { 1350 {
1360 { 1362 {
1361 /* FIXME - According to Geoff Keating, we should never 1363 /* FIXME - According to Geoff Keating, we should never
1362 have to do this; the front ends should always process 1364 have to do this; the front ends should always process
1363 the arg list from the TYPE_ARG_LIST. */ 1365 the arg list from the TYPE_ARG_LIST. */
1364 for (arg_type = DECL_ARGUMENTS (callee_t), i = 0; 1366 for (arg_type = DECL_ARGUMENTS (callee_t), i = 0;
1365 arg_type; 1367 arg_type && i < gimple_call_num_args (call);
1366 arg_type = TREE_CHAIN (arg_type), i++) 1368 arg_type = TREE_CHAIN (arg_type), i++)
1367 { 1369 {
1368 tree operand = gimple_call_arg (call, i); 1370 tree operand = gimple_call_arg (call, i);
1369 if (operand) 1371 if (operand)
1370 { 1372 {
1982 is a master clone. However, we do need to process any 1984 is a master clone. However, we do need to process any
1983 AVAIL_OVERWRITABLE functions (these are never clones) because 1985 AVAIL_OVERWRITABLE functions (these are never clones) because
1984 they may cause a type variable to escape. 1986 they may cause a type variable to escape.
1985 */ 1987 */
1986 for (node = cgraph_nodes; node; node = node->next) 1988 for (node = cgraph_nodes; node; node = node->next)
1987 if (node->analyzed) 1989 if (node->analyzed && !node->clone_of)
1988 analyze_function (node); 1990 analyze_function (node);
1989 1991
1990 1992
1991 pointer_set_destroy (visited_nodes); 1993 pointer_set_destroy (visited_nodes);
1992 visited_nodes = NULL; 1994 visited_nodes = NULL;
2109 } 2111 }
2110 2112
2111 static bool 2113 static bool
2112 gate_type_escape_vars (void) 2114 gate_type_escape_vars (void)
2113 { 2115 {
2114 return (flag_ipa_type_escape 2116 return flag_ipa_struct_reorg && flag_whole_program && (optimize > 0);
2115 /* Don't bother doing anything if the program has errors. */
2116 && !(errorcount || sorrycount));
2117 } 2117 }
2118 2118
2119 struct simple_ipa_opt_pass pass_ipa_type_escape = 2119 struct simple_ipa_opt_pass pass_ipa_type_escape =
2120 { 2120 {
2121 { 2121 {