summaryrefslogtreecommitdiff
path: root/gcc/alloc-pool.h
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-23 15:19:17 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-23 15:19:17 +0000
commit43b3fc7da8bb61d8f1c3d769b19dae4dd1b762bf (patch)
treecc64992fdaf261e074681a3e73e3d3f761077bd5 /gcc/alloc-pool.h
parent3a37a410bbfed45d04f06887c348938182369d5a (diff)
downloadgcc-43b3fc7da8bb61d8f1c3d769b19dae4dd1b762bf.tar.gz
2016-02-23 Richard Biener <rguenther@suse.de>
* alloc-pool.h (struct allocation_object): Make id member conditional on CHECKING_P again. (get_instance): Adjust. (base_pool_allocator): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233635 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/alloc-pool.h')
-rw-r--r--gcc/alloc-pool.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 085a0f9df10..8ccf089d60c 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -156,8 +156,10 @@ private:
struct allocation_object
{
+#if CHECKING_P
/* The ID of alloc pool which the object was allocated from. */
ALLOC_POOL_ID_TYPE id;
+#endif
union
{
@@ -172,6 +174,7 @@ private:
int64_t align_i;
} u;
+#if CHECKING_P
static inline allocation_object*
get_instance (void *data_ptr)
{
@@ -179,6 +182,7 @@ private:
- offsetof (allocation_object,
u.data));
}
+#endif
static inline void*
get_data (void *instance_ptr)
@@ -388,7 +392,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
header->next = NULL;
/* Mark the element to be free. */
+#if CHECKING_P
((allocation_object*) block)->id = 0;
+#endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
m_returned_free_list = header;
m_virgin_free_list += m_elt_size;
@@ -403,7 +409,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
m_elts_free--;
/* Set the ID for element. */
+#if CHECKING_P
allocation_object::get_instance (header)->id = m_id;
+#endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
return (void *)(header);
@@ -420,16 +428,20 @@ base_pool_allocator <TBlockAllocator>::remove (void *object)
{
gcc_assert (m_initialized);
gcc_assert (object
- /* Check if we free more than we allocated, which is Bad (TM). */
- && m_elts_free < m_elts_allocated
- /* Check whether the PTR was allocated from POOL. */
- && m_id == allocation_object::get_instance (object)->id);
+ /* Check if we free more than we allocated. */
+ && m_elts_free < m_elts_allocated);
+#if CHECKING_P
+ /* Check whether the PTR was allocated from POOL. */
+ gcc_assert (m_id == allocation_object::get_instance (object)->id);
+#endif
memset (object, 0xaf, size);
}
+#if CHECKING_P
/* Mark the element to be free. */
allocation_object::get_instance (object)->id = 0;
+#endif
allocation_pool_list *header = new (object) allocation_pool_list;
header->next = m_returned_free_list;