[llvm-commits] [llvm-gcc-4.2] r89415 - in /llvm-gcc-4.2/trunk/gcc: config/darwin.h llvm-backend.cpp
Bill Wendling
isanbard at gmail.com
Thu Nov 19 16:31:50 PST 2009
Author: void
Date: Thu Nov 19 18:31:31 2009
New Revision: 89415
URL: http://llvm.org/viewvc/llvm-project?rev=89415&view=rev
Log:
Adjust the alignment of strings so that they aren't over aligned. We only need
them aligned to 8-bytes instead of 16-bytes for 64-bit. And 4 instead of 8 in
32-bit.
Modified:
llvm-gcc-4.2/trunk/gcc/config/darwin.h
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin.h?rev=89415&r1=89414&r2=89415&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin.h Thu Nov 19 18:31:31 2009
@@ -698,10 +698,21 @@
char *N = (char *)alloca(strlen(fmt) + 37); \
sprintf(N, fmt, i++); \
GV->setName(N); \
+ GV->setAlignment(TARGET_64BIT ? 8 : 4); \
} \
} while (0)
/* LLVM LOCAL - end radar 6389998 */
+/* LLVM LOCAL - begin radar 7291825 */
+/* Give a constant string a sufficient alignment for the platform. */
+#define TARGET_ADJUST_CSTRING_ALIGN(GV) \
+ do { \
+ if (GV->hasInternalLinkage()) { \
+ GV->setAlignment(TARGET_64BIT ? 8 : 4); \
+ } \
+ } while (0)
+/* LLVM LOCAL - end radar 7291825 */
+
#endif
/* LLVM LOCAL end */
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=89415&r1=89414&r2=89415&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 19 18:31:31 2009
@@ -1408,8 +1408,16 @@
unsigned TargetAlign =
getTargetData().getABITypeAlignment(GV->getType()->getElementType());
if (DECL_USER_ALIGN(decl) ||
- 8 * TargetAlign < (unsigned)DECL_ALIGN(decl))
+ 8 * TargetAlign < (unsigned)DECL_ALIGN(decl)) {
GV->setAlignment(DECL_ALIGN(decl) / 8);
+ }
+#ifdef TARGET_ADJUST_CSTRING_ALIGN
+ else if (DECL_INITIAL(decl) != error_mark_node && // uninitialized?
+ DECL_INITIAL(decl) &&
+ TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) {
+ TARGET_ADJUST_CSTRING_ALIGN(GV);
+ }
+#endif
}
// Handle used decls
More information about the llvm-commits
mailing list