Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,27 @@ uint64_t PPCAIXAsmPrinter::getAliasOffset(const Constant *C) {
return 0;
}

static void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV) {
// TODO: These asserts should be updated as more support for the toc data
// transformation is added (struct support, etc.).
assert(
PointerSize >= GV->getAlign().valueOrOne().value() &&
"GlobalVariables with an alignment requirement stricter than TOC entry "
"size not supported by the toc data transformation.");

Type *GVType = GV->getValueType();
assert(GVType->isSized() && "A GlobalVariable's size must be known to be "
"supported by the toc data transformation.");
if (GV->getParent()->getDataLayout().getTypeSizeInBits(GVType) >
PointerSize * 8)
report_fatal_error(
"A GlobalVariable with size larger than a TOC entry is not currently "
"supported by the toc data transformation.");
if (GV->hasPrivateLinkage())
report_fatal_error("A GlobalVariable with private linkage is not "
"currently supported by the toc data transformation.");
}

void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
// Special LLVM global arrays have been handled at the initialization.
if (isSpecialLLVMGlobalArrayToSkip(GV) || isSpecialLLVMGlobalArrayForStaticInit(GV))
Expand All @@ -2660,7 +2681,7 @@ void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
// when we emit the .toc section.
if (GV->hasAttribute("toc-data")) {
unsigned PointerSize = GV->getParent()->getDataLayout().getPointerSize();
Subtarget->tocDataChecks(PointerSize, GV);
tocDataChecks(PointerSize, GV);
TOCDataGlobalVars.push_back(GV);
return;
}
Expand Down
22 changes: 0 additions & 22 deletions llvm/lib/Target/PowerPC/PPCSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,6 @@ bool PPCSubtarget::enableSubRegLiveness() const {
return UseSubRegLiveness;
}

void PPCSubtarget::tocDataChecks(unsigned PointerSize,
const GlobalVariable *GV) const {
// TODO: These asserts should be updated as more support for the toc data
// transformation is added (struct support, etc.).
assert(
PointerSize >= GV->getAlign().valueOrOne().value() &&
"GlobalVariables with an alignment requirement stricter than TOC entry "
"size not supported by the toc data transformation.");

Type *GVType = GV->getValueType();
assert(GVType->isSized() && "A GlobalVariable's size must be known to be "
"supported by the toc data transformation.");
if (GV->getParent()->getDataLayout().getTypeSizeInBits(GVType) >
PointerSize * 8)
report_fatal_error(
"A GlobalVariable with size larger than a TOC entry is not currently "
"supported by the toc data transformation.");
if (GV->hasPrivateLinkage())
report_fatal_error("A GlobalVariable with private linkage is not "
"currently supported by the toc data transformation.");
}

bool PPCSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
// Large code model always uses the TOC even for local symbols.
if (TM.getCodeModel() == CodeModel::Large)
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/PowerPC/PPCSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
/// True if the GV will be accessed via an indirect symbol.
bool isGVIndirectSymbol(const GlobalValue *GV) const;

void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV) const;

/// True if the ABI is descriptor based.
bool usesFunctionDescriptors() const {
// Both 32-bit and 64-bit AIX are descriptor based. For ELF only the 64-bit
Expand Down