[llvm] r233545 - Save a std::string.
Rafael Espindola
rafael.espindola at gmail.com
Mon Mar 30 06:59:06 PDT 2015
Author: rafael
Date: Mon Mar 30 08:59:06 2015
New Revision: 233545
URL: http://llvm.org/viewvc/llvm-project?rev=233545&view=rev
Log:
Save a std::string.
The group names are always symbol names, so we can use a StringRef.
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/MC/MCContext.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=233545&r1=233544&r2=233545&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Mon Mar 30 08:59:06 2015
@@ -164,7 +164,7 @@ namespace llvm {
struct ELFSectionKey {
std::string SectionName;
- std::string GroupName;
+ StringRef GroupName;
ELFSectionKey(StringRef SectionName, StringRef GroupName)
: SectionName(SectionName), GroupName(GroupName) {}
bool operator<(const ELFSectionKey &Other) const {
@@ -176,7 +176,7 @@ namespace llvm {
struct COFFSectionKey {
std::string SectionName;
- std::string GroupName;
+ StringRef GroupName;
int SelectionKey;
COFFSectionKey(StringRef SectionName, StringRef GroupName,
int SelectionKey)
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=233545&r1=233544&r2=233545&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Mon Mar 30 08:59:06 2015
@@ -291,6 +291,12 @@ const MCSectionELF *MCContext::getELFSec
unsigned Flags, unsigned EntrySize,
StringRef Group, bool Unique,
const char *BeginSymName) {
+ MCSymbol *GroupSym = nullptr;
+ if (!Group.empty()) {
+ GroupSym = GetOrCreateSymbol(Group);
+ Group = GroupSym->getName();
+ }
+
// Do the lookup, if we have a hit, return it.
auto IterBool = ELFUniquingMap.insert(
std::make_pair(ELFSectionKey{Section, Group}, nullptr));
@@ -298,10 +304,6 @@ const MCSectionELF *MCContext::getELFSec
if (!IterBool.second && !Unique)
return Entry.second;
- MCSymbol *GroupSym = nullptr;
- if (!Group.empty())
- GroupSym = GetOrCreateSymbol(Group);
-
StringRef CachedName = Entry.first.SectionName;
SectionKind Kind;
@@ -340,18 +342,19 @@ const MCSectionCOFF *
MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
SectionKind Kind, StringRef COMDATSymName,
int Selection, const char *BeginSymName) {
- // Do the lookup, if we have a hit, return it.
+ MCSymbol *COMDATSymbol = nullptr;
+ if (!COMDATSymName.empty()) {
+ COMDATSymbol = GetOrCreateSymbol(COMDATSymName);
+ COMDATSymName = COMDATSymbol->getName();
+ }
+ // Do the lookup, if we have a hit, return it.
COFFSectionKey T{Section, COMDATSymName, Selection};
auto IterBool = COFFUniquingMap.insert(std::make_pair(T, nullptr));
auto Iter = IterBool.first;
if (!IterBool.second)
return Iter->second;
- MCSymbol *COMDATSymbol = nullptr;
- if (!COMDATSymName.empty())
- COMDATSymbol = GetOrCreateSymbol(COMDATSymName);
-
MCSymbol *Begin = nullptr;
if (BeginSymName)
Begin = createTempSymbol(BeginSymName, false);
More information about the llvm-commits
mailing list