[llvm-commits] [llvm-gcc-4.2] r59991 - in /llvm-gcc-4.2/trunk/gcc: config/darwin.h llvm-backend.cpp
Bill Wendling
isanbard at gmail.com
Mon Nov 24 15:21:13 PST 2008
Author: void
Date: Mon Nov 24 17:21:13 2008
New Revision: 59991
URL: http://llvm.org/viewvc/llvm-project?rev=59991&view=rev
Log:
When a constant CFString is created, it's not given a name. LLVM gladly accepts
this and assigns it the name "_unnamed_#_#". This plays havoc with the runtime
because the runtime is expecting the name to be internal. It also prevents the
linker from coalescing these strings. The fix to generate a name for a variable
going into the _cfstring section if it doesn't already have one and it has
internal linkage.
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=59991&r1=59990&r2=59991&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin.h Mon Nov 24 17:21:13 2008
@@ -694,6 +694,21 @@
(FN)->setLinkage(Function::ExternalLinkage); \
} \
} while (0)
+
+/* A const CFString is created as an anonymous global variable. LLVM then gives
+ it the name '__unnamed_#_#'. This causes troubles with the runtime, which
+ expects the name to be internal. Give it an internal name here. */
+#define TARGET_ADJUST_CFSTRING_NAME(GV, SEC) \
+ do { \
+ if (strcmp((SEC), "__DATA, __cfstring") == 0) { \
+ static unsigned i = 0; \
+ const char *fmt = "\01L_unnamed_cfstring_%d"; \
+ char *N = (char *)alloca(strlen(fmt) + 37); \
+ sprintf(N, fmt, i++); \
+ GV->setName(N); \
+ } \
+ } while (0)
+
#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=59991&r1=59990&r2=59991&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Nov 24 17:21:13 2008
@@ -1133,6 +1133,11 @@
if (const char *Section =
LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)) {
GV->setSection(Section);
+
+#ifdef TARGET_ADJUST_CFSTRING_NAME
+ if (!GV->hasName() && GV->hasInternalLinkage())
+ TARGET_ADJUST_CFSTRING_NAME(GV, Section);
+#endif
}
#endif
}
More information about the llvm-commits
mailing list