1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[NFC][OpaquePtr] Use GlobalValue::getValueType() more

Instead of getType()->getElementType().
This commit is contained in:
Arthur Eubanks 2021-07-09 09:55:07 -07:00
parent 2013929e05
commit e29819ce26
7 changed files with 9 additions and 11 deletions

View File

@ -506,7 +506,7 @@ std::string Module::getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id,
}
// A declaration with this name already exists. Remember it.
FunctionType *FT = dyn_cast<FunctionType>(F->getType()->getElementType());
FunctionType *FT = dyn_cast<FunctionType>(F->getValueType());
auto UinItInserted = UniquedIntrinsicNames.insert({{Id, FT}, Count});
if (FT == Proto) {
// It was a declaration for our prototype. This entry was allocated in the

View File

@ -438,13 +438,12 @@ void ModuleLinker::dropReplacedComdat(
} else {
auto &Alias = cast<GlobalAlias>(GV);
Module &M = *Alias.getParent();
PointerType &Ty = *cast<PointerType>(Alias.getType());
GlobalValue *Declaration;
if (auto *FTy = dyn_cast<FunctionType>(Alias.getValueType())) {
Declaration = Function::Create(FTy, GlobalValue::ExternalLinkage, "", &M);
} else {
Declaration =
new GlobalVariable(M, Ty.getElementType(), /*isConstant*/ false,
new GlobalVariable(M, Alias.getValueType(), /*isConstant*/ false,
GlobalValue::ExternalLinkage,
/*Initializer*/ nullptr);
}

View File

@ -277,8 +277,8 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
if (!GVar)
return make_error<StringError>("Only variables can have common linkage!",
inconvertibleErrorCode());
Uncommon().CommonSize = GV->getParent()->getDataLayout().getTypeAllocSize(
GV->getType()->getElementType());
Uncommon().CommonSize =
GV->getParent()->getDataLayout().getTypeAllocSize(GV->getValueType());
Uncommon().CommonAlign = GVar->getAlignment();
}

View File

@ -1186,7 +1186,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
DIExpression *E = GVe->getExpression();
const DataLayout &DL = GV->getParent()->getDataLayout();
unsigned SizeInOctets =
DL.getTypeAllocSizeInBits(NewGV->getType()->getElementType()) / 8;
DL.getTypeAllocSizeInBits(NewGV->getValueType()) / 8;
// It is expected that the address of global optimized variable is on
// top of the stack. After optimization, value of that variable will

View File

@ -306,7 +306,7 @@ static Optional<StringRef> nameOrNone(const Value *V) {
void MemoryOpRemark::visitVariable(const Value *V,
SmallVectorImpl<VariableInfo> &Result) {
if (auto *GV = dyn_cast<GlobalVariable>(V)) {
auto *Ty = cast<PointerType>(GV->getType())->getElementType();
auto *Ty = GV->getValueType();
uint64_t Size = DL.getTypeSizeInBits(Ty).getFixedSize();
VariableInfo Var{nameOrNone(GV), Size};
if (!Var.isEmpty())

View File

@ -1032,8 +1032,8 @@ void Mapper::mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix,
Elements.push_back(NewV);
}
GV.setInitializer(ConstantArray::get(
cast<ArrayType>(GV.getType()->getElementType()), Elements));
GV.setInitializer(
ConstantArray::get(cast<ArrayType>(GV.getValueType()), Elements));
}
void Mapper::scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init,

View File

@ -28,8 +28,7 @@ static int getUsedListSize(Module &M, StringRef Name) {
auto *UsedList = M.getGlobalVariable(Name);
if (!UsedList)
return 0;
auto *UsedListBaseArrayType =
cast<ArrayType>(UsedList->getType()->getElementType());
auto *UsedListBaseArrayType = cast<ArrayType>(UsedList->getValueType());
return UsedListBaseArrayType->getNumElements();
}