Skip to content

Commit

Permalink
In preparation for removing getNameWithPrefix off of TargetMachine,
Browse files Browse the repository at this point in the history
sink the current behavior into the callers and sink
TargetMachine::getNameWithPrefix into TargetMachine::getSymbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284203 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed Oct 14, 2016
1 parent ea40df3 commit 172ce59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 8 additions & 1 deletion lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV,

if (EmitUniqueSection && UniqueSectionNames) {
Name.push_back('.');
TM.getNameWithPrefix(Name, GV, Mang, true);
Mang.getNameWithPrefix(Name, GV, false);
}
unsigned UniqueID = MCContext::GenericSectionID;
if (EmitUniqueSection && !UniqueSectionNames) {
Expand Down Expand Up @@ -817,6 +817,13 @@ static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo,
void TargetLoweringObjectFileMachO::getNameWithPrefix(
SmallVectorImpl<char> &OutName, const GlobalValue *GV,
const TargetMachine &TM) const {
if (!GV->hasPrivateLinkage()) {
// Simple case: If GV is not private, it is not important to find out if
// private labels are legal in this case or not.
getMangler().getNameWithPrefix(OutName, GV, false);
return;
}

SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
const MCSection *TheSection = SectionForGlobal(GV, GVKind, TM);
bool CannotUsePrivateLabel =
Expand Down
8 changes: 1 addition & 7 deletions lib/Target/TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,13 @@ TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name,
const GlobalValue *GV, Mangler &Mang,
bool MayAlwaysUsePrivate) const {
if (MayAlwaysUsePrivate || !GV->hasPrivateLinkage()) {
// Simple case: If GV is not private, it is not important to find out if
// private labels are legal in this case or not.
Mang.getNameWithPrefix(Name, GV, false);
return;
}
const TargetLoweringObjectFile *TLOF = getObjFileLowering();
TLOF->getNameWithPrefix(Name, GV, *this);
}

MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const {
SmallString<128> NameStr;
getNameWithPrefix(NameStr, GV, Mang);
const TargetLoweringObjectFile *TLOF = getObjFileLowering();
TLOF->getNameWithPrefix(NameStr, GV, *this);
return TLOF->getContext().getOrCreateSymbol(NameStr);
}

0 comments on commit 172ce59

Please sign in to comment.