[compiler-rt] r214033 - builtins: correct constant alignments

Saleem Abdulrasool compnerd at compnerd.org
Sat Jul 26 14:08:35 PDT 2014


Author: compnerd
Date: Sat Jul 26 16:08:34 2014
New Revision: 214033

URL: http://llvm.org/viewvc/llvm-project?rev=214033&view=rev
Log:
builtins: correct constant alignments

MMX/SSE instructions expect 128-bit alignment (16-byte) for constants that they
reference.  Correct the alignment on the constant values.  Although it is quite
possible for the data to end up aligned, there is no guarantee that this will
occur unless it is explicitly aligned to the desired location.  If the data ends
up being unaligned, the resultant binary would fault at runtime due to the
unaligned access.

As an example, the follow would fault previously:
  cc -c lib/builtins/x86_64/floatundidf.S -o floatundidf.o
  cc -c test/builtins/Unit/floatundidf_test.c -o floatundidf_test.c
  ld -m elf_x86_64 floatundidf.o floatundidf_test.o -lc -o floatundidf

However, if the object files were reversed, the data would end up aligned and
the problem would go unnoticed.

Modified:
    compiler-rt/trunk/lib/builtins/i386/floatdidf.S
    compiler-rt/trunk/lib/builtins/i386/floatundidf.S
    compiler-rt/trunk/lib/builtins/i386/floatundisf.S
    compiler-rt/trunk/lib/builtins/i386/floatundixf.S

Modified: compiler-rt/trunk/lib/builtins/i386/floatdidf.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/i386/floatdidf.S?rev=214033&r1=214032&r2=214033&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/i386/floatdidf.S (original)
+++ compiler-rt/trunk/lib/builtins/i386/floatdidf.S Sat Jul 26 16:08:34 2014
@@ -10,9 +10,14 @@
 #ifndef __ELF__
 .const
 #endif
-.balign 4
-twop52: .quad 0x4330000000000000
-twop32: .quad 0x41f0000000000000
+
+	.balign 16
+twop52:
+	.quad 0x4330000000000000
+
+	.balign 16
+twop32:
+	.quad 0x41f0000000000000
 
 #define REL_ADDR(_a)	(_a)-0b(%eax)
 

Modified: compiler-rt/trunk/lib/builtins/i386/floatundidf.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/i386/floatundidf.S?rev=214033&r1=214032&r2=214033&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/i386/floatundidf.S (original)
+++ compiler-rt/trunk/lib/builtins/i386/floatundidf.S Sat Jul 26 16:08:34 2014
@@ -20,11 +20,17 @@
 #ifndef __ELF__
 .const
 #endif
-.balign 4
-twop52: .quad 0x4330000000000000
+	.balign 16
+twop52:
+	.quad 0x4330000000000000
+
+	.balign 16
 twop84_plus_twop52:
-		.quad 0x4530000000100000
-twop84: .quad 0x4530000000000000
+	.quad 0x4530000000100000
+
+	.balign 16
+twop84:
+	.quad 0x4530000000000000
 
 #define REL_ADDR(_a)	(_a)-0b(%eax)
 

Modified: compiler-rt/trunk/lib/builtins/i386/floatundisf.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/i386/floatundisf.S?rev=214033&r1=214032&r2=214033&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/i386/floatundisf.S (original)
+++ compiler-rt/trunk/lib/builtins/i386/floatundisf.S Sat Jul 26 16:08:34 2014
@@ -55,12 +55,19 @@ END_COMPILERRT_FUNCTION(__floatundisf)
 #ifndef __ELF__
 .const
 #endif
-.balign 8
-twop52: .quad 0x4330000000000000
-		.quad 0x0000000000000fff
-sticky: .quad 0x0000000000000000
-		.long 0x00000012
-twelve:	.long 0x00000000
+	.balign 16
+twop52:
+	.quad 0x4330000000000000
+	.quad 0x0000000000000fff
+
+	.balign 16
+sticky:
+	.quad 0x0000000000000000
+	.long 0x00000012
+
+	.balign 16
+twelve:
+	.long 0x00000000
 
 #define			TWOp52			twop52-0b(%ecx)
 #define			STICKY			sticky-0b(%ecx,%eax,8)

Modified: compiler-rt/trunk/lib/builtins/i386/floatundixf.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/i386/floatundixf.S?rev=214033&r1=214032&r2=214033&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/i386/floatundixf.S (original)
+++ compiler-rt/trunk/lib/builtins/i386/floatundixf.S Sat Jul 26 16:08:34 2014
@@ -10,11 +10,17 @@
 #ifndef __ELF__
 .const
 #endif
-.balign 4
-twop52: .quad 0x4330000000000000
+	.balign 16
+twop52:
+	.quad 0x4330000000000000
+
+	.balign 16
 twop84_plus_twop52_neg:
-		.quad 0xc530000000100000
-twop84: .quad 0x4530000000000000
+	.quad 0xc530000000100000
+
+	.balign 16
+twop84:
+	.quad 0x4530000000000000
 
 #define REL_ADDR(_a)	(_a)-0b(%eax)
 





More information about the llvm-commits mailing list