[llvm-commits] [gcc-plugin] r82458 - in /gcc-plugin/trunk/gcc-patches: gc_caches.diff i386_static.diff
Duncan Sands
baldrick at free.fr
Mon Sep 21 09:30:13 PDT 2009
Author: baldrick
Date: Mon Sep 21 11:30:12 2009
New Revision: 82458
URL: http://llvm.org/viewvc/llvm-project?rev=82458&view=rev
Log:
Refresh these patches against GCC top-of-tree.
Modified:
gcc-plugin/trunk/gcc-patches/gc_caches.diff
gcc-plugin/trunk/gcc-patches/i386_static.diff
Modified: gcc-plugin/trunk/gcc-patches/gc_caches.diff
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/gcc-patches/gc_caches.diff?rev=82458&r1=82457&r2=82458&view=diff
==============================================================================
--- gcc-plugin/trunk/gcc-patches/gc_caches.diff (original)
+++ gcc-plugin/trunk/gcc-patches/gc_caches.diff Mon Sep 21 11:30:12 2009
@@ -1,7 +1,7 @@
-Index: lto/gcc/doc/plugins.texi
+Index: mainline/gcc/doc/plugins.texi
===================================================================
---- lto.orig/gcc/doc/plugins.texi 2009-09-03 21:50:47.460087851 +0200
-+++ lto/gcc/doc/plugins.texi 2009-09-03 22:17:19.831140355 +0200
+--- mainline.orig/gcc/doc/plugins.texi 2009-09-21 18:26:44.088984496 +0200
++++ mainline/gcc/doc/plugins.texi 2009-09-21 18:28:51.279983189 +0200
@@ -133,6 +133,7 @@
PLUGIN_GGC_MARKING, /* Extend the GGC marking. */
PLUGIN_GGC_END, /* Called at end of GGC. */
@@ -21,7 +21,7 @@
null, and the @code{user_data} is specific.
@section Interacting with the pass manager
-@@ -222,18 +223,20 @@
+@@ -222,16 +223,19 @@
(and conversely, these routines should usually not be used in plugins
outside of the @code{PLUGIN_GGC_MARKING} event).
@@ -32,27 +32,26 @@
+Some plugins may need to add extra GGC root tables, e.g. to handle their own
+ at code{GTY}-ed data. This can be done with the @code{PLUGIN_REGISTER_GGC_ROOTS}
+pseudo-event with a null callback and the extra root table as @code{user_data}.
-+Plugins that need to add extra GGC cache tables can likewise use the
++Plugins that want to use the @code{if_marked} hash table option can add the
++extra GGC cache tables generated by @code{gengtype} using the
+ at code{PLUGIN_REGISTER_GGC_CACHES} pseudo-event with a null callback and the
-+extra cache table as @code{user_data}. Running the @code{gengtype
- -P @file{gt-plugin.h} @var{source-dir} @var{file-list} @var{plugin*.c}
--...} utility generates this extra root table, with the PCH related
-+...} utility generates these extra tables, with the PCH related
- generated code kept wrapped with the @code{#ifdef
- GCC_PLUGIN_HAVE_PCH}, so disabled by default.
++extra cache table as @code{user_data}. Running the @code{gengtype
+ -p @var{source-dir} @var{file-list} @var{plugin*.c} ...} utility
+-generates this extra root table.
++generates these extra root tables.
You should understand the details of memory management inside GCC
-before using @code{PLUGIN_GGC_MARKING} or
-- at code{PLUGIN_REGISTER_GGC_ROOTS}. Notice that using plugins which
-+before using @code{PLUGIN_GGC_MARKING}, @code{PLUGIN_REGISTER_GGC_ROOTS} or
-+ at code{PLUGIN_REGISTER_GGC_CACHES}. Notice that using plugins which
- need these features may break the generation of precompiled headers
- [PCH], unless these plugins take specific measures.
+- at code{PLUGIN_REGISTER_GGC_ROOTS}.
++before using @code{PLUGIN_GGC_MARKING}, @code{PLUGIN_REGISTER_GGC_ROOTS}
++or @code{PLUGIN_REGISTER_GGC_CACHES}.
-Index: lto/gcc/gcc-plugin.h
+
+ @section Giving information about a plugin
+Index: mainline/gcc/gcc-plugin.h
===================================================================
---- lto.orig/gcc/gcc-plugin.h 2009-09-03 21:50:28.832084778 +0200
-+++ lto/gcc/gcc-plugin.h 2009-09-03 22:17:19.831140355 +0200
+--- mainline.orig/gcc/gcc-plugin.h 2009-09-21 18:26:44.084984608 +0200
++++ mainline/gcc/gcc-plugin.h 2009-09-21 18:28:51.279983189 +0200
@@ -40,6 +40,7 @@
PLUGIN_GGC_MARKING, /* Extend the GGC marking. */
PLUGIN_GGC_END, /* Called at end of GGC. */
@@ -72,14 +71,27 @@
*/
extern void register_callback (const char *plugin_name,
-Index: lto/gcc/ggc-common.c
+Index: mainline/gcc/ggc-common.c
===================================================================
---- lto.orig/gcc/ggc-common.c 2009-09-03 21:52:50.831086272 +0200
-+++ lto/gcc/ggc-common.c 2009-09-04 13:48:16.077072772 +0200
-@@ -116,6 +116,33 @@
- }
-
-
+--- mainline.orig/gcc/ggc-common.c 2009-09-21 18:26:44.049022422 +0200
++++ mainline/gcc/ggc-common.c 2009-09-21 18:28:51.279983189 +0200
+@@ -105,14 +105,29 @@
+ void
+ ggc_register_root_tab (const struct ggc_root_tab* rt)
+ {
+- if (!rt)
+- return;
+- if (!extra_root_vec)
+- {
+- int vlen = 32;
+- extra_root_vec = VEC_alloc (const_ggc_root_tab_t, heap, vlen);
+- }
+- VEC_safe_push (const_ggc_root_tab_t, heap, extra_root_vec, rt);
++ if (rt)
++ VEC_safe_push (const_ggc_root_tab_t, heap, extra_root_vec, rt);
++}
++
++
+/* This extra vector of dynamically registered cache_tab-s is used by
+ ggc_mark_roots and gives the ability to dynamically add new GGC cache
+ tables, for instance from some plugins; this vector is a heap one
@@ -96,50 +108,68 @@
+void
+ggc_register_cache_tab (const struct ggc_cache_tab* ct)
+{
-+ if (!ct)
-+ return;
-+ if (!extra_cache_vec)
-+ {
-+ int vlen = 32;
-+ extra_cache_vec = VEC_alloc (const_ggc_cache_tab_t, heap, vlen);
-+ }
-+ VEC_safe_push (const_ggc_cache_tab_t, heap, extra_cache_vec, ct);
-+}
-+
-+
- /* Iterate through all registered roots and mark each element. */
++ if (ct)
++ VEC_safe_push (const_ggc_cache_tab_t, heap, extra_cache_vec, ct);
+ }
+
- void
-@@ -165,6 +192,25 @@
+@@ -123,8 +138,10 @@
+ {
+ const struct ggc_root_tab *const *rt;
+ const struct ggc_root_tab *rti;
++ const_ggc_root_tab_t rtp;
+ const struct ggc_cache_tab *const *ct;
+ const struct ggc_cache_tab *cti;
++ const_ggc_cache_tab_t ctp;
+ size_t i;
+
+ for (rt = gt_ggc_deletable_rtab; *rt; rt++)
+@@ -136,18 +153,11 @@
+ for (i = 0; i < rti->nelt; i++)
+ (*rti->cb) (*(void **)((char *)rti->base + rti->stride * i));
+
+- if (extra_root_vec
+- && VEC_length(const_ggc_root_tab_t,extra_root_vec) > 0)
++ for (i = 0; VEC_iterate(const_ggc_root_tab_t, extra_root_vec, i, rtp); i++)
+ {
+- const_ggc_root_tab_t rtp = NULL;
+- for (i=0;
+- VEC_iterate(const_ggc_root_tab_t, extra_root_vec, i, rtp);
+- i++)
+- {
+- for (rti = rtp; rti->base != NULL; rti++)
+- for (i = 0; i < rti->nelt; i++)
+- (*rti->cb) (*(void **) ((char *)rti->base + rti->stride * i));
+- }
++ for (rti = rtp; rti->base != NULL; rti++)
++ for (i = 0; i < rti->nelt; i++)
++ (*rti->cb) (*(void **) ((char *)rti->base + rti->stride * i));
+ }
+
+ if (ggc_protect_identifiers)
+@@ -165,6 +175,18 @@
ggc_set_mark ((*cti->base)->entries);
}
-+ if (extra_cache_vec
-+ && VEC_length(const_ggc_cache_tab_t,extra_cache_vec) > 0)
++ for (i = 0; VEC_iterate(const_ggc_cache_tab_t, extra_cache_vec, i, ctp); i++)
+ {
-+ const_ggc_cache_tab_t ctp = NULL;
-+ for (i=0;
-+ VEC_iterate(const_ggc_cache_tab_t, extra_cache_vec, i, ctp);
-+ i++)
-+ {
-+ for (cti = ctp; cti->base != NULL; cti++)
-+ if (*cti->base)
-+ {
-+ ggc_set_mark (*cti->base);
-+ htab_traverse_noresize (*cti->base, ggc_htab_delete,
-+ CONST_CAST (void *, (const void *)cti));
-+ ggc_set_mark ((*cti->base)->entries);
-+ }
-+ }
++ for (cti = ctp; cti->base != NULL; cti++)
++ if (*cti->base)
++ {
++ ggc_set_mark (*cti->base);
++ htab_traverse_noresize (*cti->base, ggc_htab_delete,
++ CONST_CAST (void *, (const void *)cti));
++ ggc_set_mark ((*cti->base)->entries);
++ }
+ }
+
if (! ggc_protect_identifiers)
ggc_purge_stringpool ();
-Index: lto/gcc/ggc.h
+Index: mainline/gcc/ggc.h
===================================================================
---- lto.orig/gcc/ggc.h 2009-09-03 21:52:23.632087782 +0200
-+++ lto/gcc/ggc.h 2009-09-03 22:17:19.831140355 +0200
+--- mainline.orig/gcc/ggc.h 2009-09-21 18:26:44.077006832 +0200
++++ mainline/gcc/ggc.h 2009-09-21 18:28:51.279983189 +0200
@@ -275,6 +275,10 @@
plugins. Does nothing if the passed pointer is null. */
extern void ggc_register_root_tab (const struct ggc_root_tab *);
@@ -151,10 +181,10 @@
/* Return the number of bytes allocated at the indicated address. */
extern size_t ggc_get_size (const void *);
-Index: lto/gcc/plugin.c
+Index: mainline/gcc/plugin.c
===================================================================
---- lto.orig/gcc/plugin.c 2009-09-03 21:51:11.624084490 +0200
-+++ lto/gcc/plugin.c 2009-09-03 22:17:19.831140355 +0200
+--- mainline.orig/gcc/plugin.c 2009-09-21 18:26:44.092984594 +0200
++++ mainline/gcc/plugin.c 2009-09-21 18:28:51.279983189 +0200
@@ -57,6 +57,7 @@
"PLUGIN_GGC_MARKING",
"PLUGIN_GGC_END",
@@ -163,7 +193,7 @@
"PLUGIN_START_UNIT",
"PLUGIN_EVENT_LAST"
};
-@@ -501,6 +502,10 @@
+@@ -499,6 +500,10 @@
gcc_assert (!callback);
ggc_register_root_tab ((const struct ggc_root_tab*) user_data);
break;
@@ -174,7 +204,7 @@
case PLUGIN_FINISH_TYPE:
case PLUGIN_START_UNIT:
case PLUGIN_FINISH_UNIT:
-@@ -568,6 +573,7 @@
+@@ -566,6 +571,7 @@
case PLUGIN_PASS_MANAGER_SETUP:
case PLUGIN_EVENT_LAST:
case PLUGIN_REGISTER_GGC_ROOTS:
@@ -182,3 +212,79 @@
default:
gcc_assert (false);
}
+Index: mainline/gcc/testsuite/gcc.dg/plugin/ggc_caches-test-1.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ mainline/gcc/testsuite/gcc.dg/plugin/ggc_caches-test-1.c 2009-09-21 18:28:51.283987006 +0200
+@@ -0,0 +1,2 @@
++/* Test the ggc_caches plugin. */
++/* { dg-do compile } */
+Index: mainline/gcc/testsuite/gcc.dg/plugin/ggc_caches_plugin.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ mainline/gcc/testsuite/gcc.dg/plugin/ggc_caches_plugin.c 2009-09-21 18:28:51.283987006 +0200
+@@ -0,0 +1,52 @@
++/* This plugin tests the registering of GGC cache tables. */
++/* { dg-options "-O" } */
++
++#include "config.h"
++#include "system.h"
++#include "coretypes.h"
++#include "tm.h"
++#include "toplev.h"
++#include "basic-block.h"
++#include "gimple.h"
++#include "tree.h"
++#include "tree-pass.h"
++#include "intl.h"
++#include "gcc-plugin.h"
++
++int plugin_is_GPL_compatible;
++
++static GTY ((if_marked ("tree_map_base_marked_p"),
++ param_is(struct tree_map_base)))
++ htab_t cache;
++
++/* Extra GGC cache table with one entry. */
++static const struct ggc_cache_tab our_xtratab[] = {
++ {
++ &cache,
++ 1,
++ sizeof (cache),
++ >_ggc_mx_tree_map_base,
++ >_pch_nx_tree_map_base,
++ &tree_map_base_marked_p
++ },
++ LAST_GGC_CACHE_TAB
++};
++
++/* The initialization routine exposed to and called by GCC. The spec of this
++ function is defined in gcc/gcc-plugin.h.
++
++ Note that this function needs to be named exactly "plugin_init". */
++int
++plugin_init (struct plugin_name_args *plugin_info,
++ struct plugin_gcc_version *version)
++{
++ const char *plugin_name = plugin_info->base_name;
++ if (!plugin_default_version_check (version, version))
++ return 1;
++
++ register_callback (plugin_name, PLUGIN_REGISTER_GGC_CACHES, NULL,
++ (void *) our_xtratab);
++
++ /* plugin initialization succeeded */
++ return 0;
++}
+Index: mainline/gcc/testsuite/gcc.dg/plugin/plugin.exp
+===================================================================
+--- mainline.orig/gcc/testsuite/gcc.dg/plugin/plugin.exp 2009-09-21 18:26:44.109009082 +0200
++++ mainline/gcc/testsuite/gcc.dg/plugin/plugin.exp 2009-09-21 18:28:51.283987006 +0200
+@@ -49,6 +49,7 @@
+ set plugin_test_list [list \
+ { selfassign.c self-assign-test-1.c self-assign-test-2.c } \
+ { ggcplug.c ggcplug-test-1.c } \
++ { ggc_caches_plugin.c ggc_caches-test-1.c } \
+ { one_time_plugin.c one_time-test-1.c } \
+ { start_unit_plugin.c start_unit-test-1.c } \
+ { finish_unit_plugin.c finish_unit-test-1.c } \
Modified: gcc-plugin/trunk/gcc-patches/i386_static.diff
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/gcc-patches/i386_static.diff?rev=82458&r1=82457&r2=82458&view=diff
==============================================================================
--- gcc-plugin/trunk/gcc-patches/i386_static.diff (original)
+++ gcc-plugin/trunk/gcc-patches/i386_static.diff Mon Sep 21 11:30:12 2009
@@ -1,8 +1,8 @@
-Index: lto/gcc/config/i386/i386.c
+Index: mainline/gcc/config/i386/i386.c
===================================================================
---- lto.orig/gcc/config/i386/i386.c 2009-08-31 10:47:18.103197067 +0200
-+++ lto/gcc/config/i386/i386.c 2009-08-31 10:49:23.167200047 +0200
-@@ -4927,7 +4927,7 @@
+--- mainline.orig/gcc/config/i386/i386.c 2009-09-21 18:27:48.232986747 +0200
++++ mainline/gcc/config/i386/i386.c 2009-09-21 18:28:56.616984269 +0200
+@@ -4917,7 +4917,7 @@
case, we return the original mode and warn ABI change if CUM isn't
NULL. */
@@ -11,7 +11,7 @@
type_natural_mode (const_tree type, CUMULATIVE_ARGS *cum)
{
enum machine_mode mode = TYPE_MODE (type);
-@@ -5058,7 +5058,7 @@
+@@ -5048,7 +5048,7 @@
See the x86-64 PS ABI for details.
*/
@@ -20,7 +20,7 @@
classify_argument (enum machine_mode mode, const_tree type,
enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
{
-@@ -5438,7 +5438,7 @@
+@@ -5428,7 +5428,7 @@
/* Examine the argument and return set number of register required in each
class. Return 0 iff parameter should be passed in memory. */
@@ -29,7 +29,7 @@
examine_argument (enum machine_mode mode, const_tree type, int in_return,
int *int_nregs, int *sse_nregs)
{
-@@ -6118,7 +6118,7 @@
+@@ -6108,7 +6108,7 @@
/* Return true when TYPE should be 128bit aligned for 32bit argument passing
ABI. */
More information about the llvm-commits
mailing list