[llvm-commits] [dragonegg] r90076 - in /dragonegg/trunk: darwin/llvm-os.h llvm-backend.cpp
Duncan Sands
baldrick at free.fr
Sun Nov 29 06:18:34 PST 2009
Author: baldrick
Date: Sun Nov 29 08:18:33 2009
New Revision: 90076
URL: http://llvm.org/viewvc/llvm-project?rev=90076&view=rev
Log:
Port commit 89415 (void) from llvm-gcc:
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:
dragonegg/trunk/darwin/llvm-os.h
dragonegg/trunk/llvm-backend.cpp
Modified: dragonegg/trunk/darwin/llvm-os.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/darwin/llvm-os.h?rev=90076&r1=90075&r2=90076&view=diff
==============================================================================
--- dragonegg/trunk/darwin/llvm-os.h (original)
+++ dragonegg/trunk/darwin/llvm-os.h Sun Nov 29 08:18:33 2009
@@ -42,4 +42,13 @@
argvec.push_back ("--relocation-model=static")
#endif /* !TARGET_386 && !TARGET_ARM */
+/* Give a constant string a sufficient alignment for the platform. */
+/* radar 7291825 */
+#define TARGET_ADJUST_CSTRING_ALIGN(GV) \
+ do { \
+ if (GV->hasInternalLinkage()) { \
+ GV->setAlignment(TARGET_64BIT ? 8 : 4); \
+ } \
+ } while (0)
+
#endif /* LLVM_OS_H */
Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=90076&r1=90075&r2=90076&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Sun Nov 29 08:18:33 2009
@@ -1215,8 +1215,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