[llvm] 4e60132 - [NFC][OpaquePtr] Use GlobalValue::getValueType() more
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 9 09:56:01 PDT 2021
Author: Arthur Eubanks
Date: 2021-07-09T09:55:41-07:00
New Revision: 4e6013250d319a7ca4fc7fb5ba9ac7b1b28d2b4f
URL: https://github.com/llvm/llvm-project/commit/4e6013250d319a7ca4fc7fb5ba9ac7b1b28d2b4f
DIFF: https://github.com/llvm/llvm-project/commit/4e6013250d319a7ca4fc7fb5ba9ac7b1b28d2b4f.diff
LOG: [NFC][OpaquePtr] Use GlobalValue::getValueType() more
Instead of getType()->getElementType().
Added:
Modified:
llvm/lib/IR/Module.cpp
llvm/lib/Linker/LinkModules.cpp
llvm/lib/Object/IRSymtab.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
llvm/lib/Transforms/Utils/ValueMapper.cpp
llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 9b955500b6180..7c18dc0ed299f 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -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
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 98793c5873882..943c2faaf1b11 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -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);
}
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index 70655d1a26be9..bcada85a0c117 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -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();
}
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index ed67b20a4d3dd..6ac9690251e05 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -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
diff --git a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
index 0f0b551f754a2..68d4dd9d576b3 100644
--- a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
@@ -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())
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index a89c92376034d..f3afd42e61632 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -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,
diff --git a/llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp b/llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp
index 5a1d9245f1595..e1bc58fda0e38 100644
--- a/llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp
@@ -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();
}
More information about the llvm-commits
mailing list