|
From: Bart V. A. <bva...@ac...> - 2010-09-09 16:39:50
|
Hello,
As you might have noticed, since r11318 (conversion of inline
functions in drd/drd.h to gcc statement expressions) the following two
DRD regression tests are failing on PowerPC:
+ drd/tests/annotate_smart_pointer (stderr)
+ drd/tests/annotate_static (stderr)
Inspection of the assembly code generated by gcc learned that this was
caused by gcc 4.3.0 not translating the VALGRIND_DO_CLIENT_REQUEST()
macro correctly. The pointer to the array with the client request
number and the client request argument was put by gcc in register r9
instead of r4, despite the fact that the pointer to this array is put
in register r4 explicitly (__asm__("r4")) and that this pointer is
specified as an input parameter of the inline assembly code in that
macro. If I interpret the gcc documentation correctly, this is a gcc
bug. A quote from
http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Local-Reg-Vars.html:
[ ... ]
However, using the variable as an asm operand guarantees that the
specified register is used for the operand.
[ ... ]
The patch below is a workaround for this issue. Feedback about this
patch is welcome.
Index: include/valgrind.h
===================================================================
--- include/valgrind.h (revision 11347)
+++ include/valgrind.h (working copy)
@@ -445,8 +445,8 @@
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
\
{ unsigned long long int _zzq_args[6]; \
- register unsigned long long int _zzq_result __asm__("r3"); \
- register unsigned long long int* _zzq_ptr __asm__("r4"); \
+ register unsigned long long int _zzq_result; \
+ register unsigned long long int* _zzq_ptr; \
_zzq_args[0] = (unsigned long long int)(_zzq_request); \
_zzq_args[1] = (unsigned long long int)(_zzq_arg1); \
_zzq_args[2] = (unsigned long long int)(_zzq_arg2); \
@@ -454,12 +454,15 @@
_zzq_args[4] = (unsigned long long int)(_zzq_arg4); \
_zzq_args[5] = (unsigned long long int)(_zzq_arg5); \
_zzq_ptr = _zzq_args; \
- __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
+ __asm__ volatile("mr 3,%1\n\t" /*default*/ \
+ "mr 4,%2\n\t" /*ptr*/ \
+ __SPECIAL_INSTRUCTION_PREAMBLE \
/* %R3 = client_request ( %R4 ) */ \
- "or 1,1,1" \
- : "=r" (_zzq_result) \
- : "0" (_zzq_default), "r" (_zzq_ptr) \
- : "cc", "memory"); \
+ "or 1,1,1\n\t" \
+ "mr %0,3" /*result*/ \
+ : "=b" (_zzq_result) \
+ : "b" (_zzq_default), "b" (_zzq_ptr) \
+ : "cc", "memory", "r3", "r4"); \
_zzq_rlval = _zzq_result; \
}
Bart.
|