]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: implement CLEAR_CALLER_SAVED_REGS for memcheck tests
authorPetar Jovanovic <mips32r2@gmail.com>
Mon, 5 Dec 2016 16:03:21 +0000 (16:03 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Mon, 5 Dec 2016 16:03:21 +0000 (16:03 +0000)
Implement CLEAR_CALLER_SAVED_REGS macro that is used for some memcheck
tests. This is done in order to clear temporary registers that still
might be holding pointers to lost memory regions.
Similar change has been made for PPC.

This fixes the following tests:

memcheck/tests/leak-cases-full           (stderr)
memcheck/tests/leak-cases-summary        (stderr)
memcheck/tests/leak-cycle                (stderr)
memcheck/tests/lks                       (stderr)

on some MIPS platforms.

Patch by Aleksandar Rikalo.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16172

memcheck/tests/leak.h

index ac8a64cf08d3b84ac1a18740a5a3cae59ee33536..ac63070c67054f8c9f3bc4a8b79bb0f3163dfe25 100644 (file)
    __asm__ __volatile__( "li 11, 0" : : :/*trash*/"r11" ); \
    __asm__ __volatile__( "li 12, 0" : : :/*trash*/"r12" ); \
   } while (0)
+#elif (__mips == 32)
+#define CLEAR_CALLER_SAVED_REGS                                              \
+   do {                                                                      \
+      __asm__ __volatile__ ("move $1,  $0 \n\t"   /* at = 0 */               \
+                            "move $2,  $0 \n\t"   /* v0 = 0 */               \
+                            "move $3,  $0 \n\t"   /* v1 = 0 */               \
+                            "move $4,  $0 \n\t"   /* a0 = 0 */               \
+                            "move $5,  $0 \n\t"   /* a1 = 0 */               \
+                            "move $6,  $0 \n\t"   /* a2 = 0 */               \
+                            "move $7,  $0 \n\t"   /* a3 = 0 */               \
+                            "move $8,  $0 \n\t"   /* t0 = 0 */               \
+                            "move $9,  $0 \n\t"   /* t1 = 0 */               \
+                            "move $10, $0 \n\t"   /* t2 = 0 */               \
+                            "move $11, $0 \n\t"   /* t3 = 0 */               \
+                            "move $12, $0 \n\t"   /* t4 = 0 */               \
+                            "move $13, $0 \n\t"   /* t5 = 0 */               \
+                            "move $14, $0 \n\t"   /* t6 = 0 */               \
+                            "move $15, $0 \n\t"   /* t7 = 0 */               \
+                            "move $24, $0 \n\t"   /* t8 = 0 */               \
+                            "move $25, $0 \n\t"   /* t9 = 0 */               \
+                            : : : "$1", "$2", "$3", "$4", "$5", "$6", "$7",  \
+                                  "$8", "$9", "$10", "$11", "$12", "$13",    \
+                                  "$14", "$15", "$24", "$25");               \
+   } while (0)
+#elif (__mips == 64)
+#define CLEAR_CALLER_SAVED_REGS                                              \
+   do {                                                                      \
+      __asm__ __volatile__ ("move $1,  $0 \n\t"  /* at = 0 */                \
+                            "move $2,  $0 \n\t"  /* v0 = 0 */                \
+                            "move $3,  $0 \n\t"  /* v1 = 0 */                \
+                            "move $4,  $0 \n\t"  /* a0 = 0 */                \
+                            "move $5,  $0 \n\t"  /* a1 = 0 */                \
+                            "move $6,  $0 \n\t"  /* a2 = 0 */                \
+                            "move $7,  $0 \n\t"  /* a3 = 0 */                \
+                            "move $8,  $0 \n\t"  /* a4 = 0 */                \
+                            "move $9,  $0 \n\t"  /* a5 = 0 */                \
+                            "move $10, $0 \n\t"  /* a6 = 0 */                \
+                            "move $11, $0 \n\t"  /* a7 = 0 */                \
+                            "move $12, $0 \n\t"  /* t0 = 0 */                \
+                            "move $13, $0 \n\t"  /* t1 = 0 */                \
+                            "move $14, $0 \n\t"  /* t2 = 0 */                \
+                            "move $15, $0 \n\t"  /* t3 = 0 */                \
+                            "move $24, $0 \n\t"  /* t8 = 0 */                \
+                            "move $25, $0 \n\t"  /* t9 = 0 */                \
+                            : : : "$1", "$2", "$3", "$4", "$5", "$6", "$7",  \
+                                  "$8", "$9", "$10", "$11", "$12", "$13",    \
+                                  "$14", "$15", "$24", "$25");               \
+   } while (0)
 #else
 #define CLEAR_CALLER_SAVED_REGS  /*nothing*/
 #endif