mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add back r201608, r201622, r201624 and r201625
r201608 made llvm corretly handle private globals with MachO. r201622 fixed a bug in it and r201624 and r201625 were changes for using private linkage, assuming that llvm would do the right thing. They all got reverted because r201608 introduced a crash in LTO. This patch includes a fix for that. The issue was that TargetLoweringObjectFile now has to be initialized before we can mangle names of private globals. This is trivially true during the normal codegen pipeline (the asm printer does it), but LTO has to do it manually. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201700 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@@ -1426,3 +1428,30 @@ bool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TargetLoweringBase::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;
|
||||
}
|
||||
SectionKind GVKind =
|
||||
TargetLoweringObjectFile::getKindForGlobal(GV, getTargetMachine());
|
||||
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
|
||||
const MCSection *TheSection =
|
||||
TLOF.SectionForGlobal(GV, GVKind, Mang, getTargetMachine());
|
||||
bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection);
|
||||
Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel);
|
||||
}
|
||||
|
||||
MCSymbol *TargetLoweringBase::getSymbol(const GlobalValue *GV,
|
||||
Mangler &Mang) const {
|
||||
SmallString<60> NameStr;
|
||||
getNameWithPrefix(NameStr, GV, Mang);
|
||||
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
|
||||
return TLOF.getContext().GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user