[compiler-rt] r269297 - [mips][sanitizer_common] Don't use `ld` in internal_clone() on 32-bit MIPS.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 07:21:34 PDT 2016


Author: dsanders
Date: Thu May 12 09:21:33 2016
New Revision: 269297

URL: http://llvm.org/viewvc/llvm-project?rev=269297&view=rev
Log:
[mips][sanitizer_common] Don't use `ld` in internal_clone() on 32-bit MIPS.

Summary:
On a 32-bit MIPS, the `ld` instruction does not exist. However, GAS has an `ld`
macro that expands to a pair of `lw` instructions which load to a pair of
registers (reg, and reg+1). This macro is not available in the Integrated
Assembler and its use causes -fintegrated-as builds to fail. Even if it were
available, the behaviour on 32-bit MIPS would be incorrect since the current
usage of `ld` causes the code to clobber $5 (which is supposed to hold
child_stack). It also clobbers $k0 which is reserved for kernel use.

Aside from enabling builds with the integrated assembler, there is no functional
change since internal_clone() is only used by StopTheWorld() which is only used
by 64-bit sanitizers.

Reviewers: kcc, sagar

Subscribers: mohit.bhakkad, jaydeep, sagar, llvm-commits

Differential Revision: http://reviews.llvm.org/D18753

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=269297&r1=269296&r2=269297&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Thu May 12 09:21:33 2016
@@ -969,8 +969,18 @@ uptr internal_clone(int (*fn)(void *), v
                        "bnez $2,1f;\n"
 
                        /* Call "fn(arg)". */
+#if SANITIZER_WORDSIZE == 32
+#ifdef __BIG_ENDIAN__
+                       "lw $25,4($29);\n"
+                       "lw $4,12($29);\n"
+#else
+                       "lw $25,0($29);\n"
+                       "lw $4,8($29);\n"
+#endif
+#else
                        "ld $25,0($29);\n"
                        "ld $4,8($29);\n"
+#endif
                        "jal $25;\n"
 
                        /* Call _exit($v0). */




More information about the llvm-commits mailing list