aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Target/TargetLoweringObjectFile.cpp6
-rw-r--r--test/CodeGen/X86/global-sections.ll13
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp
index 4f07f9036a..e0b294173f 100644
--- a/lib/Target/TargetLoweringObjectFile.cpp
+++ b/lib/Target/TargetLoweringObjectFile.cpp
@@ -16,6 +16,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/GlobalVariable.h"
+#include "llvm/Support/Mangler.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetOptions.h"
@@ -407,9 +408,8 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
// into a 'uniqued' section name, create and return the section now.
if (Kind.isWeak()) {
const char *Prefix = getSectionPrefixForUniqueGlobal(Kind);
- // FIXME: Use mangler interface (PR4584).
- std::string Name = Prefix+GV->getNameStr();
- return getOrCreateSection(Name.c_str(), false, Kind.getKind());
+ std::string Name = Mang->makeNameProper(GV->getNameStr());
+ return getOrCreateSection((Prefix+Name).c_str(), false, Kind.getKind());
}
if (Kind.isText()) return TextSection;
diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll
index ddfb352391..18a585a983 100644
--- a/test/CodeGen/X86/global-sections.ll
+++ b/test/CodeGen/X86/global-sections.ll
@@ -55,3 +55,16 @@
; DARWIN: _G5:
; DARWIN: .long 47
+
+; PR4584
+@"foo bar" = linkonce global i32 42
+
+; LINUX: .type foo_20_bar,@object
+; LINUX:.section .gnu.linkonce.d.foo_20_bar,"aw",@progbits
+; LINUX: .weak foo_20_bar
+; LINUX: foo_20_bar:
+
+; DARWIN: .section __DATA,__datacoal_nt,coalesced
+; DARWIN: .globl "_foo bar"
+; DARWIN: .weak_definition "_foo bar"
+; DARWIN: "_foo bar":