Skip to content

Commit 00ba2a6

Browse files
authored
[AIX][TOC] Fix buildbot failures from commit b4ae8df (llvm#85303)
The following tests fail when built with Address and Undefined sanitizers: CodeGen/PowerPC/basic-toc-data-def.ll CodeGen/PowerPC/toc-data-large-array2.ll Subtarget may be null in emitGlobalVariable, for example in the testcase where we have no functions in the IR. The fix moves this function from PPCSubtarget to a static helper function. This only fails with sanitizers because the Subtarget is not used in the member function.
1 parent c56bd7a commit 00ba2a6

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,27 @@ uint64_t PPCAIXAsmPrinter::getAliasOffset(const Constant *C) {
26512651
return 0;
26522652
}
26532653

2654+
static void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV) {
2655+
// TODO: These asserts should be updated as more support for the toc data
2656+
// transformation is added (struct support, etc.).
2657+
assert(
2658+
PointerSize >= GV->getAlign().valueOrOne().value() &&
2659+
"GlobalVariables with an alignment requirement stricter than TOC entry "
2660+
"size not supported by the toc data transformation.");
2661+
2662+
Type *GVType = GV->getValueType();
2663+
assert(GVType->isSized() && "A GlobalVariable's size must be known to be "
2664+
"supported by the toc data transformation.");
2665+
if (GV->getParent()->getDataLayout().getTypeSizeInBits(GVType) >
2666+
PointerSize * 8)
2667+
report_fatal_error(
2668+
"A GlobalVariable with size larger than a TOC entry is not currently "
2669+
"supported by the toc data transformation.");
2670+
if (GV->hasPrivateLinkage())
2671+
report_fatal_error("A GlobalVariable with private linkage is not "
2672+
"currently supported by the toc data transformation.");
2673+
}
2674+
26542675
void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
26552676
// Special LLVM global arrays have been handled at the initialization.
26562677
if (isSpecialLLVMGlobalArrayToSkip(GV) || isSpecialLLVMGlobalArrayForStaticInit(GV))
@@ -2660,7 +2681,7 @@ void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
26602681
// when we emit the .toc section.
26612682
if (GV->hasAttribute("toc-data")) {
26622683
unsigned PointerSize = GV->getParent()->getDataLayout().getPointerSize();
2663-
Subtarget->tocDataChecks(PointerSize, GV);
2684+
tocDataChecks(PointerSize, GV);
26642685
TOCDataGlobalVars.push_back(GV);
26652686
return;
26662687
}

llvm/lib/Target/PowerPC/PPCSubtarget.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,6 @@ bool PPCSubtarget::enableSubRegLiveness() const {
185185
return UseSubRegLiveness;
186186
}
187187

188-
void PPCSubtarget::tocDataChecks(unsigned PointerSize,
189-
const GlobalVariable *GV) const {
190-
// TODO: These asserts should be updated as more support for the toc data
191-
// transformation is added (struct support, etc.).
192-
assert(
193-
PointerSize >= GV->getAlign().valueOrOne().value() &&
194-
"GlobalVariables with an alignment requirement stricter than TOC entry "
195-
"size not supported by the toc data transformation.");
196-
197-
Type *GVType = GV->getValueType();
198-
assert(GVType->isSized() && "A GlobalVariable's size must be known to be "
199-
"supported by the toc data transformation.");
200-
if (GV->getParent()->getDataLayout().getTypeSizeInBits(GVType) >
201-
PointerSize * 8)
202-
report_fatal_error(
203-
"A GlobalVariable with size larger than a TOC entry is not currently "
204-
"supported by the toc data transformation.");
205-
if (GV->hasPrivateLinkage())
206-
report_fatal_error("A GlobalVariable with private linkage is not "
207-
"currently supported by the toc data transformation.");
208-
}
209-
210188
bool PPCSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
211189
// Large code model always uses the TOC even for local symbols.
212190
if (TM.getCodeModel() == CodeModel::Large)

llvm/lib/Target/PowerPC/PPCSubtarget.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
245245
/// True if the GV will be accessed via an indirect symbol.
246246
bool isGVIndirectSymbol(const GlobalValue *GV) const;
247247

248-
void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV) const;
249-
250248
/// True if the ABI is descriptor based.
251249
bool usesFunctionDescriptors() const {
252250
// Both 32-bit and 64-bit AIX are descriptor based. For ELF only the 64-bit

0 commit comments

Comments
 (0)