[tree-ssa libmudflap] ia64 tweaks
Frank Ch. Eigler
fche@redhat.com
Wed Jun 25 21:47:00 GMT 2003
Hi -
The following patches make mudflap tests run better on ia64,
and no worse on other platforms.
- FChE
2003-06-25 Frank Ch. Eigler <fche@redhat.com>
* mf-hooks.c (alloca): Separate into stub.
(__mf_wrap_alloca_indirect): New function. Use CALL_REAL
malloc/free for alloca blocks.
(pthread_create): Tolerate failing pthread_attr_get* calls.
* mf-runtime.c (__mf_fini): Call __mf_wrap_alloca_indirect.
* mf-impl.h (CALL_WRAP): Remove macro.
* testsuite/libmudflap.c/pass21-frag.c: Include <alloca.h>.
* testsuite/libmudflap.c/pass23-frag.c: Include more struct
Index: mf-hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks.c,v
retrieving revision 1.1.2.38
diff -u -w -s -r1.1.2.38 mf-hooks.c
--- mf-hooks.c 19 Jun 2003 19:29:35 -0000 1.1.2.38
+++ mf-hooks.c 25 Jun 2003 20:32:24 -0000
@@ -397,11 +397,12 @@
#endif
-/* This wrapper is a little different, as it's implemented in terms
- of the wrapped malloc/free functions. */
#ifdef WRAP_alloca
-#undef alloca
-WRAPPER(void *, alloca, size_t c)
+
+/* This wrapper is a little different, as it's called indirectly from
+ __mf_fini also to clean up pending allocations. */
+void *
+__mf_wrap_alloca_indirect (size_t c)
{
DECLARE (void *, malloc, size_t);
DECLARE (void, free, void *);
@@ -416,7 +417,7 @@
static struct alloca_tracking *alloca_history = NULL;
void *stack = __builtin_frame_address (0);
- char *result;
+ void *result;
struct alloca_tracking *track;
TRACE ("mf: %s\n", __PRETTY_FUNCTION__);
@@ -429,7 +430,8 @@
((uintptr_t) alloca_history->stack DEEPER_THAN (uintptr_t) stack))
{
struct alloca_tracking *next = alloca_history->next;
- CALL_WRAP (free, alloca_history->ptr);
+ __mf_unregister (alloca_history->ptr, 0);
+ CALL_REAL (free, alloca_history->ptr);
CALL_REAL (free, alloca_history);
alloca_history = next;
}
@@ -442,7 +444,7 @@
sizeof (struct alloca_tracking));
if (LIKELY (track != NULL))
{
- result = (char *) CALL_WRAP (malloc, c);
+ result = CALL_REAL (malloc, c);
if (UNLIKELY (result == NULL))
{
CALL_REAL (free, track);
@@ -450,6 +452,7 @@
}
else
{
+ __mf_register (result, c, __MF_TYPE_HEAP, "alloca region");
track->ptr = result;
track->stack = stack;
track->next = alloca_history;
@@ -460,6 +463,14 @@
return result;
}
+
+
+#undef alloca
+WRAPPER(void *, alloca, size_t c)
+{
+ return __mf_wrap_alloca_indirect (c);
+}
+
#endif
@@ -1076,14 +1087,13 @@
else
pthread_attr_init (& override_attr);
- /* Get supplied attributes. Give up on error. */
+ /* Get supplied attributes, if any. */
/* XXX: consider using POSIX2K attr_getstack() */
if (pthread_attr_getstackaddr (& override_attr, & override_stack) != 0 ||
pthread_attr_getstacksize (& override_attr, & override_stacksize) != 0)
{
- errno = EAGAIN;
- pi->used_p = 0;
- return -1;
+ override_stack = NULL;
+ override_stacksize = 0;
}
/* Do we need to allocate the new thread's stack? */
Index: mf-impl.h
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-impl.h,v
retrieving revision 1.1.2.22
diff -u -w -s -r1.1.2.22 mf-impl.h
--- mf-impl.h 18 Jun 2003 17:08:32 -0000 1.1.2.22
+++ mf-impl.h 25 Jun 2003 20:32:24 -0000
@@ -289,8 +289,6 @@
(((__mf_fn_ ## fname)(__mf_dynamic[dyn_ ## fname].pointer)) (__VA_ARGS__)));})
#define CALL_BACKUP(fname, ...) \
__mf_0fn_ ## fname(__VA_ARGS__)
-#define CALL_WRAP(fname, ...) \
- (__wrap_ ## fname (__VA_ARGS__))
#else /* not PIC --> static library */
@@ -302,8 +300,6 @@
__real_ ## fname (__VA_ARGS__)
#define CALL_BACKUP(fname, ...) \
__real_ ## fname(__VA_ARGS__)
-#define CALL_WRAP(fname, ...) \
- __wrap_ ## fname (__VA_ARGS__)
#endif /* PIC */
Index: mf-runtime.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-runtime.c,v
retrieving revision 1.1.2.41
diff -u -w -s -r1.1.2.41 mf-runtime.c
--- mf-runtime.c 19 Jun 2003 19:29:35 -0000 1.1.2.41
+++ mf-runtime.c 25 Jun 2003 20:32:24 -0000
@@ -1483,7 +1483,8 @@
break;
}
if (smoothed_new_shift < 0) smoothed_new_shift = __mf_lc_shift;
- /* Converge toward this slowly to reduce flapping. */ smoothed_new_shift = 0.9*smoothed_new_shift + 0.1*i;
+ /* Converge toward this slowly to reduce flapping. */
+ smoothed_new_shift = 0.9*smoothed_new_shift + 0.1*i;
new_shift = (unsigned) (smoothed_new_shift + 0.5);
assert (new_shift >= 0 && new_shift < sizeof (uintptr_t)*8);
@@ -1930,10 +1931,10 @@
if (__mf_opts.print_leaks && (__mf_opts.mudflap_mode == mode_check))
{
unsigned l;
- DECLARE (void *, alloca, size_t n);
+ extern void * __mf_wrap_alloca_indirect (size_t c);
/* Free up any remaining alloca()'d blocks. */
- (void) CALL_WRAP (alloca, 0); /* XXX: doesn't work in shared mode. */
+ __mf_wrap_alloca_indirect (0);
__mf_describe_object (NULL); /* Reset description epoch. */
__mf_report_leaks (NULL); /* Reset cumulative count. */
l = __mf_report_leaks (__mf_object_root);
Index: testsuite/libmudflap.c/pass21-frag.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass21-frag.c,v
retrieving revision 1.1.2.1
diff -u -w -s -r1.1.2.1 pass21-frag.c
--- testsuite/libmudflap.c/pass21-frag.c 26 Feb 2003 19:00:38 -0000 1.1.2.1
+++ testsuite/libmudflap.c/pass21-frag.c 25 Jun 2003 20:32:24 -0000
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <alloca.h>
int main ()
{
char *boo, *foo;
Index: testsuite/libmudflap.c/pass23-frag.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass23-frag.c,v
retrieving revision 1.1.2.2
diff -u -w -s -r1.1.2.2 pass23-frag.c
--- testsuite/libmudflap.c/pass23-frag.c 5 Mar 2003 20:21:19 -0000 1.1.2.2
+++ testsuite/libmudflap.c/pass23-frag.c 25 Jun 2003 20:32:24 -0000
@@ -8,6 +8,7 @@
int nothing : 1;
int part2 : 5;
int lots_more_nothing : 3;
+ int some_padding; /* for 64-bit hosts */
float some_more_nothing;
double yet_more_nothing;
};
More information about the Gcc-patches
mailing list