OpaquePtr: switch to GlobalValue::getValueType in a few places. NFC.

llvm-svn: 365770
This commit is contained in:
Tim Northover 2019-07-11 13:13:02 +00:00
parent 208712ddb1
commit 31c7657e49
3 changed files with 5 additions and 8 deletions

View File

@ -724,7 +724,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitGlobalVariable(GlobalVariable &GV){
if (!GV.hasDefinitiveInitializer())
return unknown();
APInt Size(IntTyBits, DL.getTypeAllocSize(GV.getType()->getElementType()));
APInt Size(IntTyBits, DL.getTypeAllocSize(GV.getValueType()));
return std::make_pair(align(Size, GV.getAlignment()), Zero);
}

View File

@ -495,7 +495,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
const DataLayout &DL = GV->getParent()->getDataLayout();
uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType());
uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
// If the alignment is specified, we *must* obey it. Overaligning a global
// with a specified alignment is a prompt way to break globals emitted to
@ -1300,7 +1300,7 @@ void AsmPrinter::emitGlobalIndirectSymbol(Module &M,
else
assert(GIS.hasLocalLinkage() && "Invalid alias or ifunc linkage");
bool IsFunction = GIS.getType()->getPointerElementType()->isFunctionTy();
bool IsFunction = GIS.getValueType()->isFunctionTy();
// Treat bitcasts of functions as functions also. This is important at least
// on WebAssembly where object and function addresses can't alias each other.

View File

@ -238,10 +238,7 @@ bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
return false;
}
Type *GType = GVar->getType();
if (PointerType *PT = dyn_cast<PointerType>(GType))
GType = PT->getElementType();
Type *GType = GVar->getValueType();
if (isa<ArrayType>(GType)) {
LLVM_DEBUG(dbgs() << "no, is an array\n");
return false;
@ -341,7 +338,7 @@ unsigned HexagonTargetObjectFile::getSmallestAddressableSize(const Type *Ty,
MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
const Type *GTy = GO->getType()->getElementType();
const Type *GTy = GO->getValueType();
unsigned Size = getSmallestAddressableSize(GTy, GO, TM);
// If we have -ffunction-section or -fdata-section then we should emit the