[llvm-commits] [llvm-gcc-4.2] r95961 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Evan Cheng
evan.cheng at apple.com
Thu Feb 11 18:32:56 PST 2010
Author: evancheng
Date: Thu Feb 11 20:32:56 2010
New Revision: 95961
URL: http://llvm.org/viewvc/llvm-project?rev=95961&view=rev
Log:
Give writable literal cstrings (i.e. in data) internal linkage instead of private linkage. This makes sure it has a label which the linker can see so it doesn't get merged into its previous label.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=95961&r1=95960&r2=95961&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Feb 11 20:32:56 2010
@@ -8388,6 +8388,12 @@
bool StringIsConstant = !flag_writable_strings ||
darwin_constant_cfstring_p(exp);
+ // Literal cstrings in data section needs a label the linker can
+ // see to prevent it from being merged into its previous label.
+ GlobalValue::LinkageTypes Linkage = StringIsConstant
+ ? GlobalValue::PrivateLinkage
+ : GlobalValue::InternalLinkage;
+
GlobalVariable **SlotP = 0;
if (StringIsConstant) {
// Cache the string constants to avoid making obvious duplicate strings that
@@ -8400,8 +8406,7 @@
// Create a new string global.
GlobalVariable *GV = new GlobalVariable(*TheModule, Init->getType(),
- StringIsConstant,
- GlobalVariable::PrivateLinkage, Init,
+ StringIsConstant, Linkage, Init,
".str");
GV->setAlignment(get_constant_alignment(exp) / 8);
More information about the llvm-commits
mailing list