* [PATCH] Fix --enable-gather-detailed-mem-stats build.
@ 2020-12-16 9:05 Martin Liška
2020-12-16 9:08 ` Iain Sandoe
0 siblings, 1 reply; 8+ messages in thread
From: Martin Liška @ 2020-12-16 9:05 UTC (permalink / raw)
To: gcc-patches; +Cc: Nathan Sidwell, Jakub Jelinek
The build suffers from the static initialization order fiasco:
==30085== Invalid read of size 4
==30085== at 0x1D451CD: hash_table_mod1 (hash-table.h:344)
==30085== by 0x1D451CD: hash_table<hash_map<mem_alloc_description<vec_usage>::mem_location_hash, vec_usage*, simple_hashmap_traits<default_hash_traits<mem_alloc_description<vec_usage>::mem_location_hash>, vec_usage*> >::hash_entry, false, xcallocator>::find_with_hash(mem_location* const&, unsigned int) (hash-table.h:911)
==30085== by 0x1D411F7: get (hash-map.h:185)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:417)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:451)
==30085== by 0x1D411F7: vec_prefix::register_overhead(void*, unsigned long, unsigned long, char const*, int, char const*) (vec.c:132)
==30085== by 0xA2DB28: reserve<loc_spans::span> (vec.h:294)
==30085== by 0xA2DB28: vec<loc_spans::span, va_heap, vl_ptr>::reserve(unsigned int, bool, char const*, int, char const*) [clone .isra.0] (vec.h:1778)
==30085== by 0x9039C7: reserve_exact (vec.h:1798)
==30085== by 0x9039C7: create (vec.h:1813)
==30085== by 0x9039C7: loc_spans (module.cc:3281)
==30085== by 0x9039C7: __static_initialization_and_destruction_0 (module.cc:3340)
==30085== by 0x9039C7: _GLOBAL__sub_I_map_context_from (gt-cp-module.h:360)
==30085== by 0x1E00F6C: __libc_csu_init (elf-init.c:89)
==30085== by 0x4FFF0DD: (below main) (in /lib64/libc-2.32.so)
==30085== Address 0x28 is not stack'd, malloc'd or (recently) free'd
So vec_mem_desc is not initialized before a static member in module.cc.
That can be fixed by usage of GNU C++ extension init_priority.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
* vec.c: Use init_priority for vec_mem_desc.
---
gcc/vec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/vec.c b/gcc/vec.c
index a28899170ed..1671f26c045 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -121,7 +121,8 @@ public:
};
/* Vector memory description. */
-static mem_alloc_description <vec_usage> vec_mem_desc;
+static mem_alloc_description <vec_usage> vec_mem_desc
+ __attribute__ ((init_priority (101)));
/* Account the overhead. */
--
2.29.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:05 [PATCH] Fix --enable-gather-detailed-mem-stats build Martin Liška
@ 2020-12-16 9:08 ` Iain Sandoe
2020-12-16 9:20 ` Martin Liška
0 siblings, 1 reply; 8+ messages in thread
From: Iain Sandoe @ 2020-12-16 9:08 UTC (permalink / raw)
To: Martin Liška; +Cc: gcc-patches, Jakub Jelinek, Nathan Sidwell
Martin Liška <mliska@suse.cz> wrote:
> The build suffers from the static initialization order fiasco:
>
> ==30085== Invalid read of size 4
> ==30085== at 0x1D451CD: hash_table_mod1 (hash-table.h:344)
> ==30085== by 0x1D451CD:
> hash_table<hash_map<mem_alloc_description<vec_usage>::mem_location_hash,
> vec_usage*,
> simple_hashmap_traits<default_hash_traits<mem_alloc_description<vec_usage>::mem_location_hash>,
> vec_usage*> >::hash_entry, false,
> xcallocator>::find_with_hash(mem_location* const&, unsigned int)
> (hash-table.h:911)
> ==30085== by 0x1D411F7: get (hash-map.h:185)
> ==30085== by 0x1D411F7: register_descriptor (mem-stats.h:417)
> ==30085== by 0x1D411F7: register_descriptor (mem-stats.h:451)
> ==30085== by 0x1D411F7: vec_prefix::register_overhead(void*, unsigned
> long, unsigned long, char const*, int, char const*) (vec.c:132)
> ==30085== by 0xA2DB28: reserve<loc_spans::span> (vec.h:294)
> ==30085== by 0xA2DB28: vec<loc_spans::span, va_heap,
> vl_ptr>::reserve(unsigned int, bool, char const*, int, char const*)
> [clone .isra.0] (vec.h:1778)
> ==30085== by 0x9039C7: reserve_exact (vec.h:1798)
> ==30085== by 0x9039C7: create (vec.h:1813)
> ==30085== by 0x9039C7: loc_spans (module.cc:3281)
> ==30085== by 0x9039C7: __static_initialization_and_destruction_0
> (module.cc:3340)
> ==30085== by 0x9039C7: _GLOBAL__sub_I_map_context_from
> (gt-cp-module.h:360)
> ==30085== by 0x1E00F6C: __libc_csu_init (elf-init.c:89)
> ==30085== by 0x4FFF0DD: (below main) (in /lib64/libc-2.32.so)
> ==30085== Address 0x28 is not stack'd, malloc'd or (recently) free'd
>
> So vec_mem_desc is not initialized before a static member in module.cc.
> That can be fixed by usage of GNU C++ extension init_priority.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> * vec.c: Use init_priority for vec_mem_desc.
> ---
> gcc/vec.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/vec.c b/gcc/vec.c
> index a28899170ed..1671f26c045 100644
> --- a/gcc/vec.c
> +++ b/gcc/vec.c
> @@ -121,7 +121,8 @@ public:
> };
> /* Vector memory description. */
> -static mem_alloc_description <vec_usage> vec_mem_desc;
> +static mem_alloc_description <vec_usage> vec_mem_desc
> + __attribute__ ((init_priority (101)));
This will break bootstrap on targets without init_priority (e.g. Darwin)
Iain
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:08 ` Iain Sandoe
@ 2020-12-16 9:20 ` Martin Liška
2020-12-16 9:26 ` Jakub Jelinek
0 siblings, 1 reply; 8+ messages in thread
From: Martin Liška @ 2020-12-16 9:20 UTC (permalink / raw)
To: Iain Sandoe; +Cc: gcc-patches, Jakub Jelinek, Nathan Sidwell
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
On 12/16/20 10:08 AM, Iain Sandoe wrote:
> This will break bootstrap on targets without init_priority (e.g. Darwin)
All right, based on the chat on IRC, I suggest using C static constructor
with corresponding priority.
Ready to be installed?
Thanks,
Martin
[-- Attachment #2: 0001-Fix-enable-gather-detailed-mem-stats-build.patch --]
[-- Type: text/x-patch, Size: 4239 bytes --]
From 4ecf4f8df8d5b6b75cfe7cc5df90176e0a5014b8 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 16 Dec 2020 10:02:10 +0100
Subject: [PATCH] Fix --enable-gather-detailed-mem-stats build.
The build suffers from the static initialization order fiasco:
==30085== Invalid read of size 4
==30085== at 0x1D451CD: hash_table_mod1 (hash-table.h:344)
==30085== by 0x1D451CD: hash_table<hash_map<mem_alloc_description<vec_usage>::mem_location_hash, vec_usage*, simple_hashmap_traits<default_hash_traits<mem_alloc_description<vec_usage>::mem_location_hash>, vec_usage*> >::hash_entry, false, xcallocator>::find_with_hash(mem_location* const&, unsigned int) (hash-table.h:911)
==30085== by 0x1D411F7: get (hash-map.h:185)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:417)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:451)
==30085== by 0x1D411F7: vec_prefix::register_overhead(void*, unsigned long, unsigned long, char const*, int, char const*) (vec.c:132)
==30085== by 0xA2DB28: reserve<loc_spans::span> (vec.h:294)
==30085== by 0xA2DB28: vec<loc_spans::span, va_heap, vl_ptr>::reserve(unsigned int, bool, char const*, int, char const*) [clone .isra.0] (vec.h:1778)
==30085== by 0x9039C7: reserve_exact (vec.h:1798)
==30085== by 0x9039C7: create (vec.h:1813)
==30085== by 0x9039C7: loc_spans (module.cc:3281)
==30085== by 0x9039C7: __static_initialization_and_destruction_0 (module.cc:3340)
==30085== by 0x9039C7: _GLOBAL__sub_I_map_context_from (gt-cp-module.h:360)
==30085== by 0x1E00F6C: __libc_csu_init (elf-init.c:89)
==30085== by 0x4FFF0DD: (below main) (in /lib64/libc-2.32.so)
==30085== Address 0x28 is not stack'd, malloc'd or (recently) free'd
So vec_mem_desc is not initialized before a static member in module.cc.
We can fix it by using constructor attribute.
gcc/ChangeLog:
* vec.c (init_vec_mem_desc): New function.
(vec_prefix::register_overhead): Use vec_mem_desc as pointer
now.
(vec_prefix::release_overhead): Likewise.
(dump_vec_loc_statistics): Likewise.
---
gcc/vec.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/gcc/vec.c b/gcc/vec.c
index a28899170ed..ac91400c2df 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -121,7 +121,17 @@ public:
};
/* Vector memory description. */
-static mem_alloc_description <vec_usage> vec_mem_desc;
+static mem_alloc_description <vec_usage> *vec_mem_desc;
+
+/* Static constructor for vec_mem_desc that happens before ithe initialization
+ of all static variables. */
+
+static void
+__attribute__((constructor (101)))
+init_vec_mem_desc (void)
+{
+ vec_mem_desc = new mem_alloc_description<vec_usage> ();
+}
/* Account the overhead. */
@@ -129,10 +139,10 @@ void
vec_prefix::register_overhead (void *ptr, size_t elements,
size_t element_size MEM_STAT_DECL)
{
- vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN, false
- FINAL_PASS_MEM_STAT);
+ vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN, false
+ FINAL_PASS_MEM_STAT);
vec_usage *usage
- = vec_mem_desc.register_instance_overhead (elements * element_size, ptr);
+ = vec_mem_desc->register_instance_overhead (elements * element_size, ptr);
usage->m_element_size = element_size;
usage->m_items += elements;
if (usage->m_items_peak < usage->m_items)
@@ -145,11 +155,11 @@ void
vec_prefix::release_overhead (void *ptr, size_t size, size_t elements,
bool in_dtor MEM_STAT_DECL)
{
- if (!vec_mem_desc.contains_descriptor_for_instance (ptr))
- vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN,
+ if (!vec_mem_desc->contains_descriptor_for_instance (ptr))
+ vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN,
false FINAL_PASS_MEM_STAT);
- vec_usage *usage = vec_mem_desc.release_instance_overhead (ptr, size,
- in_dtor);
+ vec_usage *usage = vec_mem_desc->release_instance_overhead (ptr, size,
+ in_dtor);
usage->m_items -= elements;
}
@@ -183,7 +193,7 @@ vec_prefix::calculate_allocation_1 (unsigned alloc, unsigned desired)
void
dump_vec_loc_statistics (void)
{
- vec_mem_desc.dump (VEC_ORIGIN);
+ vec_mem_desc->dump (VEC_ORIGIN);
}
#if CHECKING_P
--
2.29.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:20 ` Martin Liška
@ 2020-12-16 9:26 ` Jakub Jelinek
2020-12-16 9:31 ` Martin Liška
2020-12-16 9:38 ` Rainer Orth
0 siblings, 2 replies; 8+ messages in thread
From: Jakub Jelinek @ 2020-12-16 9:26 UTC (permalink / raw)
To: Martin Liška; +Cc: Iain Sandoe, gcc-patches, Nathan Sidwell
On Wed, Dec 16, 2020 at 10:20:09AM +0100, Martin Liška wrote:
> So vec_mem_desc is not initialized before a static member in module.cc.
> We can fix it by using constructor attribute.
>
> gcc/ChangeLog:
>
> * vec.c (init_vec_mem_desc): New function.
> (vec_prefix::register_overhead): Use vec_mem_desc as pointer
> now.
> (vec_prefix::release_overhead): Likewise.
> (dump_vec_loc_statistics): Likewise.
> ---
> gcc/vec.c | 28 +++++++++++++++++++---------
> 1 file changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/vec.c b/gcc/vec.c
> index a28899170ed..ac91400c2df 100644
> --- a/gcc/vec.c
> +++ b/gcc/vec.c
> @@ -121,7 +121,17 @@ public:
> };
>
> /* Vector memory description. */
> -static mem_alloc_description <vec_usage> vec_mem_desc;
> +static mem_alloc_description <vec_usage> *vec_mem_desc;
> +
> +/* Static constructor for vec_mem_desc that happens before ithe initialization
s/ithe/the/
> + of all static variables. */
> +
> +static void
> +__attribute__((constructor (101)))
I think this needs to be guarded based on which compiler is used to compile
GCC. Perhaps we could say that we don't support
--enable-gather-detailed-mem-stats when the compiler isn't built by GCC (or
other compiler that supports the constructor attribute) and #error on that.
> +init_vec_mem_desc (void)
> +{
> + vec_mem_desc = new mem_alloc_description<vec_usage> ();
> +}
>
> /* Account the overhead. */
>
> @@ -129,10 +139,10 @@ void
> vec_prefix::register_overhead (void *ptr, size_t elements,
> size_t element_size MEM_STAT_DECL)
> {
> - vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN, false
> - FINAL_PASS_MEM_STAT);
> + vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN, false
> + FINAL_PASS_MEM_STAT);
> vec_usage *usage
> - = vec_mem_desc.register_instance_overhead (elements * element_size, ptr);
> + = vec_mem_desc->register_instance_overhead (elements * element_size, ptr);
> usage->m_element_size = element_size;
> usage->m_items += elements;
> if (usage->m_items_peak < usage->m_items)
> @@ -145,11 +155,11 @@ void
> vec_prefix::release_overhead (void *ptr, size_t size, size_t elements,
> bool in_dtor MEM_STAT_DECL)
> {
> - if (!vec_mem_desc.contains_descriptor_for_instance (ptr))
> - vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN,
> + if (!vec_mem_desc->contains_descriptor_for_instance (ptr))
> + vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN,
> false FINAL_PASS_MEM_STAT);
> - vec_usage *usage = vec_mem_desc.release_instance_overhead (ptr, size,
> - in_dtor);
> + vec_usage *usage = vec_mem_desc->release_instance_overhead (ptr, size,
> + in_dtor);
> usage->m_items -= elements;
> }
>
> @@ -183,7 +193,7 @@ vec_prefix::calculate_allocation_1 (unsigned alloc, unsigned desired)
> void
> dump_vec_loc_statistics (void)
> {
> - vec_mem_desc.dump (VEC_ORIGIN);
> + vec_mem_desc->dump (VEC_ORIGIN);
> }
>
> #if CHECKING_P
Jakub
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:26 ` Jakub Jelinek
@ 2020-12-16 9:31 ` Martin Liška
2020-12-16 9:38 ` Rainer Orth
1 sibling, 0 replies; 8+ messages in thread
From: Martin Liška @ 2020-12-16 9:31 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Iain Sandoe, gcc-patches, Nathan Sidwell
On 12/16/20 10:26 AM, Jakub Jelinek wrote:
> I think this needs to be guarded based on which compiler is used to compile
> GCC.
Do you mean basing that on __GNUC__?
> Perhaps we could say that we don't support
> --enable-gather-detailed-mem-stats when the compiler isn't built by GCC (or
> other compiler that supports the constructor attribute) and #error on that.
Yes, it's a reasonable requirement I would say.
Martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:26 ` Jakub Jelinek
2020-12-16 9:31 ` Martin Liška
@ 2020-12-16 9:38 ` Rainer Orth
2020-12-16 9:51 ` Martin Liška
1 sibling, 1 reply; 8+ messages in thread
From: Rainer Orth @ 2020-12-16 9:38 UTC (permalink / raw)
To: Jakub Jelinek via Gcc-patches
Cc: Martin Liška, Jakub Jelinek, Iain Sandoe, Nathan Sidwell
Hi Jakub,
> On Wed, Dec 16, 2020 at 10:20:09AM +0100, Martin Liška wrote:
>> So vec_mem_desc is not initialized before a static member in module.cc.
>> We can fix it by using constructor attribute.
[...]
>> + of all static variables. */
>> +
>> +static void
>> +__attribute__((constructor (101)))
>
> I think this needs to be guarded based on which compiler is used to compile
> GCC. Perhaps we could say that we don't support
> --enable-gather-detailed-mem-stats when the compiler isn't built by GCC (or
> other compiler that supports the constructor attribute) and #error on that.
not only that: if a target doesn't support constructor priorities (like
Solaris 11.3, unlike 11.4), this makes gcc error out.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:38 ` Rainer Orth
@ 2020-12-16 9:51 ` Martin Liška
2021-01-04 12:33 ` Richard Biener
0 siblings, 1 reply; 8+ messages in thread
From: Martin Liška @ 2020-12-16 9:51 UTC (permalink / raw)
To: Rainer Orth, Jakub Jelinek via Gcc-patches
Cc: Jakub Jelinek, Iain Sandoe, Nathan Sidwell
[-- Attachment #1: Type: text/plain, Size: 921 bytes --]
On 12/16/20 10:38 AM, Rainer Orth wrote:
> Hi Jakub,
>
>> On Wed, Dec 16, 2020 at 10:20:09AM +0100, Martin Liška wrote:
>>> So vec_mem_desc is not initialized before a static member in module.cc.
>>> We can fix it by using constructor attribute.
> [...]
>>> + of all static variables. */
>>> +
>>> +static void
>>> +__attribute__((constructor (101)))
>>
>> I think this needs to be guarded based on which compiler is used to compile
>> GCC. Perhaps we could say that we don't support
>> --enable-gather-detailed-mem-stats when the compiler isn't built by GCC (or
>> other compiler that supports the constructor attribute) and #error on that.
>
> not only that: if a target doesn't support constructor priorities (like
> Solaris 11.3, unlike 11.4), this makes gcc error out.
>
> Rainer
>
I see, I'm then suggesting version 3 of the patch that does not depend
on a constructor.
Thoughts?
Thanks,
Martin
Martin
[-- Attachment #2: 0001-Fix-enable-gather-detailed-mem-stats-build.patch --]
[-- Type: text/x-patch, Size: 4023 bytes --]
From 3ac0d258887426b30d3e1885841b1bdf4e53100b Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 16 Dec 2020 10:02:10 +0100
Subject: [PATCH] Fix --enable-gather-detailed-mem-stats build.
The build suffers from the static initialization order fiasco:
==30085== Invalid read of size 4
==30085== at 0x1D451CD: hash_table_mod1 (hash-table.h:344)
==30085== by 0x1D451CD: hash_table<hash_map<mem_alloc_description<vec_usage>::mem_location_hash, vec_usage*, simple_hashmap_traits<default_hash_traits<mem_alloc_description<vec_usage>::mem_location_hash>, vec_usage*> >::hash_entry, false, xcallocator>::find_with_hash(mem_location* const&, unsigned int) (hash-table.h:911)
==30085== by 0x1D411F7: get (hash-map.h:185)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:417)
==30085== by 0x1D411F7: register_descriptor (mem-stats.h:451)
==30085== by 0x1D411F7: vec_prefix::register_overhead(void*, unsigned long, unsigned long, char const*, int, char const*) (vec.c:132)
==30085== by 0xA2DB28: reserve<loc_spans::span> (vec.h:294)
==30085== by 0xA2DB28: vec<loc_spans::span, va_heap, vl_ptr>::reserve(unsigned int, bool, char const*, int, char const*) [clone .isra.0] (vec.h:1778)
==30085== by 0x9039C7: reserve_exact (vec.h:1798)
==30085== by 0x9039C7: create (vec.h:1813)
==30085== by 0x9039C7: loc_spans (module.cc:3281)
==30085== by 0x9039C7: __static_initialization_and_destruction_0 (module.cc:3340)
==30085== by 0x9039C7: _GLOBAL__sub_I_map_context_from (gt-cp-module.h:360)
==30085== by 0x1E00F6C: __libc_csu_init (elf-init.c:89)
==30085== by 0x4FFF0DD: (below main) (in /lib64/libc-2.32.so)
==30085== Address 0x28 is not stack'd, malloc'd or (recently) free'd
So vec_mem_desc is not initialized before a static member in module.cc.
gcc/ChangeLog:
* vec.c (vec_prefix::register_overhead): Initialize vec_mem_desc
if it is NULL.
(vec_prefix::release_overhead): Use pointer type for
vec_mem_desc.
(dump_vec_loc_statistics): Likewise.
---
gcc/vec.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/gcc/vec.c b/gcc/vec.c
index a28899170ed..7df0f54605e 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -121,7 +121,7 @@ public:
};
/* Vector memory description. */
-static mem_alloc_description <vec_usage> vec_mem_desc;
+static mem_alloc_description <vec_usage> *vec_mem_desc = NULL;
/* Account the overhead. */
@@ -129,10 +129,13 @@ void
vec_prefix::register_overhead (void *ptr, size_t elements,
size_t element_size MEM_STAT_DECL)
{
- vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN, false
- FINAL_PASS_MEM_STAT);
+ if (vec_mem_desc == NULL)
+ vec_mem_desc = new mem_alloc_description<vec_usage> ();
+
+ vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN, false
+ FINAL_PASS_MEM_STAT);
vec_usage *usage
- = vec_mem_desc.register_instance_overhead (elements * element_size, ptr);
+ = vec_mem_desc->register_instance_overhead (elements * element_size, ptr);
usage->m_element_size = element_size;
usage->m_items += elements;
if (usage->m_items_peak < usage->m_items)
@@ -145,11 +148,11 @@ void
vec_prefix::release_overhead (void *ptr, size_t size, size_t elements,
bool in_dtor MEM_STAT_DECL)
{
- if (!vec_mem_desc.contains_descriptor_for_instance (ptr))
- vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN,
+ if (!vec_mem_desc->contains_descriptor_for_instance (ptr))
+ vec_mem_desc->register_descriptor (ptr, VEC_ORIGIN,
false FINAL_PASS_MEM_STAT);
- vec_usage *usage = vec_mem_desc.release_instance_overhead (ptr, size,
- in_dtor);
+ vec_usage *usage = vec_mem_desc->release_instance_overhead (ptr, size,
+ in_dtor);
usage->m_items -= elements;
}
@@ -183,7 +186,7 @@ vec_prefix::calculate_allocation_1 (unsigned alloc, unsigned desired)
void
dump_vec_loc_statistics (void)
{
- vec_mem_desc.dump (VEC_ORIGIN);
+ vec_mem_desc->dump (VEC_ORIGIN);
}
#if CHECKING_P
--
2.29.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix --enable-gather-detailed-mem-stats build.
2020-12-16 9:51 ` Martin Liška
@ 2021-01-04 12:33 ` Richard Biener
0 siblings, 0 replies; 8+ messages in thread
From: Richard Biener @ 2021-01-04 12:33 UTC (permalink / raw)
To: Martin Liška
Cc: Rainer Orth, Jakub Jelinek via Gcc-patches, Jakub Jelinek,
Iain Sandoe, Nathan Sidwell
On Wed, Dec 16, 2020 at 10:52 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 12/16/20 10:38 AM, Rainer Orth wrote:
> > Hi Jakub,
> >
> >> On Wed, Dec 16, 2020 at 10:20:09AM +0100, Martin Liška wrote:
> >>> So vec_mem_desc is not initialized before a static member in module.cc.
> >>> We can fix it by using constructor attribute.
> > [...]
> >>> + of all static variables. */
> >>> +
> >>> +static void
> >>> +__attribute__((constructor (101)))
> >>
> >> I think this needs to be guarded based on which compiler is used to compile
> >> GCC. Perhaps we could say that we don't support
> >> --enable-gather-detailed-mem-stats when the compiler isn't built by GCC (or
> >> other compiler that supports the constructor attribute) and #error on that.
> >
> > not only that: if a target doesn't support constructor priorities (like
> > Solaris 11.3, unlike 11.4), this makes gcc error out.
> >
> > Rainer
> >
>
> I see, I'm then suggesting version 3 of the patch that does not depend
> on a constructor.
>
> Thoughts?
I guess that works. Note we're trying to limit the number of dynamic
initializers so the new loc_spans one would be another candidate to
dynamically allocate instead.
But OK.
Thanks,
Richard.
> Thanks,
> Martin
>
> Martin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-04 12:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 9:05 [PATCH] Fix --enable-gather-detailed-mem-stats build Martin Liška
2020-12-16 9:08 ` Iain Sandoe
2020-12-16 9:20 ` Martin Liška
2020-12-16 9:26 ` Jakub Jelinek
2020-12-16 9:31 ` Martin Liška
2020-12-16 9:38 ` Rainer Orth
2020-12-16 9:51 ` Martin Liška
2021-01-04 12:33 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).