[llvm] 3eae1bf - [llvm] Remove uses of getNonOpaquePointerElementType() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 02:52:23 PDT 2023
Author: Nikita Popov
Date: 2023-07-14T11:52:13+02:00
New Revision: 3eae1bf4c2c768dfadb03ede0e43168dbac4e683
URL: https://github.com/llvm/llvm-project/commit/3eae1bf4c2c768dfadb03ede0e43168dbac4e683
DIFF: https://github.com/llvm/llvm-project/commit/3eae1bf4c2c768dfadb03ede0e43168dbac4e683.diff
LOG: [llvm] Remove uses of getNonOpaquePointerElementType() (NFC)
Added:
Modified:
llvm/include/llvm/FuzzMutate/OpDescriptor.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Function.cpp
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/FuzzMutate/OpDescriptor.h b/llvm/include/llvm/FuzzMutate/OpDescriptor.h
index f3b185dfedd8d9..00a8ea0e5babc6 100644
--- a/llvm/include/llvm/FuzzMutate/OpDescriptor.h
+++ b/llvm/include/llvm/FuzzMutate/OpDescriptor.h
@@ -166,14 +166,13 @@ static inline SourcePred sizedPtrType() {
if (V->isSwiftError())
return false;
- if (const auto *PtrT = dyn_cast<PointerType>(V->getType()))
- return PtrT->isOpaque() ||
- PtrT->getNonOpaquePointerElementType()->isSized();
- return false;
+ return V->getType()->isPointerTy();
};
auto Make = [](ArrayRef<Value *>, ArrayRef<Type *> Ts) {
std::vector<Constant *> Result;
+ // TODO: This doesn't really make sense with opaque pointers,
+ // as the pointer type will always be the same.
for (Type *T : Ts)
if (T->isSized())
Result.push_back(UndefValue::get(PointerType::getUnqual(T)));
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 0f5b7270c53648..dfac88fa2d0efa 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -955,14 +955,10 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
// Otherwise form a regular getelementptr. Recompute the indices so that
// we eliminate over-indexing of the notional static type array bounds.
// This makes it easy to determine if the getelementptr is "inbounds".
- // Also, this helps GlobalOpt do SROA on GlobalVariables.
- // For GEPs of GlobalValues, use the value type even for opaque pointers.
- // Otherwise use an i8 GEP.
+ // For GEPs of GlobalValues, use the value type, otherwise use an i8 GEP.
if (auto *GV = dyn_cast<GlobalValue>(Ptr))
SrcElemTy = GV->getValueType();
- else if (!PTy->isOpaque())
- SrcElemTy = PTy->getNonOpaquePointerElementType();
else
SrcElemTy = Type::getInt8Ty(Ptr->getContext());
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index f2bfb4ee5fdda9..9416c7f5a03e35 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -977,18 +977,11 @@ void ModuleBitcodeWriter::writeTypeTable() {
case Type::PointerTyID: {
PointerType *PTy = cast<PointerType>(T);
unsigned AddressSpace = PTy->getAddressSpace();
- if (PTy->isOpaque()) {
- // OPAQUE_POINTER: [address space]
- Code = bitc::TYPE_CODE_OPAQUE_POINTER;
- TypeVals.push_back(AddressSpace);
- if (AddressSpace == 0)
- AbbrevToUse = OpaquePtrAbbrev;
- } else {
- // POINTER: [pointee type, address space]
- Code = bitc::TYPE_CODE_POINTER;
- TypeVals.push_back(VE.getTypeID(PTy->getNonOpaquePointerElementType()));
- TypeVals.push_back(AddressSpace);
- }
+ // OPAQUE_POINTER: [address space]
+ Code = bitc::TYPE_CODE_OPAQUE_POINTER;
+ TypeVals.push_back(AddressSpace);
+ if (AddressSpace == 0)
+ AbbrevToUse = OpaquePtrAbbrev;
break;
}
case Type::FunctionTyID: {
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 6df22f150929c5..be4a3ed79d88c4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -595,16 +595,9 @@ void TypePrinting::print(Type *Ty, raw_ostream &OS) {
}
case Type::PointerTyID: {
PointerType *PTy = cast<PointerType>(Ty);
- if (PTy->isOpaque()) {
- OS << "ptr";
- if (unsigned AddressSpace = PTy->getAddressSpace())
- OS << " addrspace(" << AddressSpace << ')';
- return;
- }
- print(PTy->getNonOpaquePointerElementType(), OS);
+ OS << "ptr";
if (unsigned AddressSpace = PTy->getAddressSpace())
OS << " addrspace(" << AddressSpace << ')';
- OS << '*';
return;
}
case Type::ArrayTyID: {
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 3037457d4fffb0..57163ad2e816bf 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -917,11 +917,6 @@ static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
std::string Result;
if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
Result += "p" + utostr(PTyp->getAddressSpace());
- // Opaque pointer doesn't have pointee type information, so we just mangle
- // address space for opaque pointer.
- if (!PTyp->isOpaque())
- Result += getMangledTypeStr(PTyp->getNonOpaquePointerElementType(),
- HasUnnamedType);
} else if (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
Result += "a" + utostr(ATyp->getNumElements()) +
getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index ebbfd5acc7237c..1f373270f951ba 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -990,18 +990,8 @@ static StringRef solveTypeName(Type *Ty) {
return "__floating_type_";
}
- if (auto *PtrTy = dyn_cast<PointerType>(Ty)) {
- if (PtrTy->isOpaque())
- return "PointerType";
- Type *PointeeTy = PtrTy->getNonOpaquePointerElementType();
- auto Name = solveTypeName(PointeeTy);
- if (Name == "UnknownType")
- return "PointerType";
- SmallString<16> Buffer;
- Twine(Name + "_Ptr").toStringRef(Buffer);
- auto *MDName = MDString::get(Ty->getContext(), Buffer.str());
- return MDName->getString();
- }
+ if (Ty->isPointerTy())
+ return "PointerType";
if (Ty->isStructTy()) {
if (!cast<StructType>(Ty)->hasName())
@@ -2599,10 +2589,7 @@ static void eliminateSwiftErrorArgument(Function &F, Argument &Arg,
IRBuilder<> Builder(F.getEntryBlock().getFirstNonPHIOrDbg());
auto ArgTy = cast<PointerType>(Arg.getType());
- // swifterror arguments are required to have pointer-to-pointer type,
- // so create a pointer-typed alloca with opaque pointers.
- auto ValueTy = ArgTy->isOpaque() ? PointerType::getUnqual(F.getContext())
- : ArgTy->getNonOpaquePointerElementType();
+ auto ValueTy = PointerType::getUnqual(F.getContext());
// Reduce to the alloca case:
More information about the llvm-commits
mailing list