diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index 824f0a9a88299..eaaf10c4eec68 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -109,9 +109,6 @@ class CGCallee { AbstractInfo = abstractInfo; assert(functionPtr && "configuring callee without function pointer"); assert(functionPtr->getType()->isPointerTy()); - assert(functionPtr->getType()->isOpaquePointerTy() || - functionPtr->getType()->getNonOpaquePointerElementType() - ->isFunctionTy()); } static CGCallee forBuiltin(unsigned builtinID, diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 038268d0705f8..6cc919afa0285 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4888,10 +4888,8 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr, } } - // For opaque pointers an all-zero GEP is a no-op. For typed pointers, - // it may be equivalent to a bitcast. - if (Ptr->getType()->getScalarType()->isOpaquePointerTy() && - Ptr->getType() == GEPTy && + // All-zero GEP is a no-op, unless it performs a vector splat. + if (Ptr->getType() == GEPTy && all_of(Indices, [](const auto *V) { return match(V, m_Zero()); })) return Ptr; diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index dcb3476a2d840..ed9e1d6ebfa21 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2675,7 +2675,7 @@ bool LLParser::parseType(Type *&Result, const Twine &Msg, bool AllowVoid) { // Handle "ptr" opaque pointer type. // // Type ::= ptr ('addrspace' '(' uint32 ')')? - if (Result->isOpaquePointerTy()) { + if (Result->isPointerTy()) { unsigned AddrSpace; if (parseOptionalAddrSpace(AddrSpace)) return true; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index c31f2afadc516..4095545240ca1 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1381,17 +1381,6 @@ unsigned BitcodeReader::getVirtualTypeID(Type *Ty, return It->second; } -#ifndef NDEBUG - if (!Ty->isOpaquePointerTy()) { - assert(Ty->getNumContainedTypes() == ChildTypeIDs.size() && - "Wrong number of contained types"); - for (auto Pair : zip(Ty->subtypes(), ChildTypeIDs)) { - assert(std::get<0>(Pair) == getTypeByID(std::get<1>(Pair)) && - "Incorrect contained type ID"); - } - } -#endif - unsigned TypeID = TypeList.size(); TypeList.push_back(Ty); if (!ChildTypeIDs.empty()) diff --git a/llvm/lib/FuzzMutate/Operations.cpp b/llvm/lib/FuzzMutate/Operations.cpp index 48455c781629f..408f35879acd3 100644 --- a/llvm/lib/FuzzMutate/Operations.cpp +++ b/llvm/lib/FuzzMutate/Operations.cpp @@ -196,9 +196,7 @@ OpDescriptor llvm::fuzzerop::gepDescriptor(unsigned Weight) { auto buildGEP = [](ArrayRef Srcs, Instruction *Inst) { // TODO: It would be better to generate a random type here, rather than // generating a random value and picking its type. - Type *Ty = Srcs[0]->getType()->isOpaquePointerTy() - ? Srcs[1]->getType() - : Srcs[0]->getType()->getNonOpaquePointerElementType(); + Type *Ty = Srcs[1]->getType(); auto Indices = ArrayRef(Srcs).drop_front(2); return GetElementPtrInst::Create(Ty, Srcs[0], Indices, "G", Inst); }; diff --git a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp index bbacfedf456d3..548ba7956fd5a 100644 --- a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp +++ b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp @@ -211,10 +211,8 @@ Value *RandomIRBuilder::newSource(BasicBlock &BB, ArrayRef Insts, IP = ++I->getIterator(); assert(IP != BB.end() && "guaranteed by the findPointer"); } - // For opaque pointers, pick the type independently. - Type *AccessTy = Ptr->getType()->isOpaquePointerTy() - ? RS.getSelection()->getType() - : Ptr->getType()->getNonOpaquePointerElementType(); + // Pick the type independently. + Type *AccessTy = RS.getSelection()->getType(); auto *NewLoad = new LoadInst(AccessTy, Ptr, "L", &*IP); // Only sample this load if it really matches the descriptor diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 964e51e545210..f7b6d54013de5 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -793,7 +793,7 @@ LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) { } LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) { - return unwrap(Ty)->isOpaquePointerTy(); + return true; } LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) { diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp index ce4262e593b6e..399bff72b8ae6 100644 --- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -596,20 +596,6 @@ static void checkAsyncFuncPointer(const Instruction *I, Value *V) { auto *AsyncFuncPtrAddr = dyn_cast(V->stripPointerCasts()); if (!AsyncFuncPtrAddr) fail(I, "llvm.coro.id.async async function pointer not a global", V); - - if (AsyncFuncPtrAddr->getType()->isOpaquePointerTy()) - return; - - auto *StructTy = cast( - AsyncFuncPtrAddr->getType()->getNonOpaquePointerElementType()); - if (StructTy->isOpaque() || !StructTy->isPacked() || - StructTy->getNumElements() != 2 || - !StructTy->getElementType(0)->isIntegerTy(32) || - !StructTy->getElementType(1)->isIntegerTy(32)) - fail(I, - "llvm.coro.id.async async function pointer argument's type is not " - "<{i32, i32}>", - V); } void CoroIdAsyncInst::checkWellFormed() const { diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 69e64bdb0de0e..03e8a2507b45c 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -423,10 +423,9 @@ GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) { unsigned BitWidth = DL.getIndexTypeSizeInBits(PtrTy); MapVector VariableOffsets; APInt ConstantOffset(BitWidth, 0); - if (PtrTy->isOpaquePointerTy() && - GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) { - // For opaque pointers, convert into offset representation, to recognize - // equivalent address calculations that use different type encoding. + if (GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) { + // Convert into offset representation, to recognize equivalent address + // calculations that use different type encoding. LLVMContext &Context = GEP->getContext(); E.opcode = GEP->getOpcode(); E.type = nullptr; @@ -439,8 +438,8 @@ GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) { E.varargs.push_back( lookupOrAdd(ConstantInt::get(Context, ConstantOffset))); } else { - // If converting to offset representation fails (for typed pointers and - // scalable vectors), fall back to type-based implementation: + // If converting to offset representation fails (for scalable vectors), + // fall back to type-based implementation: E.opcode = GEP->getOpcode(); E.type = GEP->getSourceElementType(); for (Use &Op : GEP->operands()) diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index f6848d1ea838a..983a75e1d708d 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -1628,12 +1628,6 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI, IRB.SetInsertPoint(&LI); - if (auto *TypedPtrTy = LI.getPointerOperandType(); - !TypedPtrTy->isOpaquePointerTy() && SI.getType() != TypedPtrTy) { - TV = IRB.CreateBitOrPointerCast(TV, TypedPtrTy, ""); - FV = IRB.CreateBitOrPointerCast(FV, TypedPtrTy, ""); - } - LoadInst *TL = IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(), LI.getName() + ".sroa.speculate.load.true"); @@ -1702,11 +1696,6 @@ static void rewriteMemOpOfSelect(SelectInst &SI, T &I, } CondMemOp.insertBefore(NewMemOpBB->getTerminator()); Value *Ptr = SI.getOperand(1 + SuccIdx); - if (auto *PtrTy = Ptr->getType(); - !PtrTy->isOpaquePointerTy() && - PtrTy != CondMemOp.getPointerOperandType()) - Ptr = BitCastInst::CreatePointerBitCastOrAddrSpaceCast( - Ptr, CondMemOp.getPointerOperandType(), "", &CondMemOp); CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr); if (isa(I)) { CondMemOp.setName(I.getName() + (IsThen ? ".then" : ".else") + ".val"); @@ -1769,8 +1758,6 @@ static bool rewriteSelectInstMemOps(SelectInst &SI, static Value *getAdjustedPtr(IRBuilderTy &IRB, const DataLayout &DL, Value *Ptr, APInt Offset, Type *PointerTy, const Twine &NamePrefix) { - assert(Ptr->getType()->isOpaquePointerTy() && - "Only opaque pointers supported"); if (Offset != 0) Ptr = IRB.CreateInBoundsGEP(IRB.getInt8Ty(), Ptr, IRB.getInt(Offset), NamePrefix + "sroa_idx"); diff --git a/llvm/tools/llvm-stress/llvm-stress.cpp b/llvm/tools/llvm-stress/llvm-stress.cpp index 722120d7aae81..d1cf1607b94be 100644 --- a/llvm/tools/llvm-stress/llvm-stress.cpp +++ b/llvm/tools/llvm-stress/llvm-stress.cpp @@ -341,9 +341,7 @@ struct LoadModifier: public Modifier { void Act() override { // Try to use predefined pointers. If non-exist, use undef pointer value; Value *Ptr = getRandomPointerValue(); - Type *Ty = Ptr->getType()->isOpaquePointerTy() - ? pickType() - : Ptr->getType()->getNonOpaquePointerElementType(); + Type *Ty = pickType(); Value *V = new LoadInst(Ty, Ptr, "L", BB->getTerminator()); PT->push_back(V); } @@ -356,9 +354,7 @@ struct StoreModifier: public Modifier { void Act() override { // Try to use predefined pointers. If non-exist, use undef pointer value; Value *Ptr = getRandomPointerValue(); - Type *ValTy = Ptr->getType()->isOpaquePointerTy() - ? pickType() - : Ptr->getType()->getNonOpaquePointerElementType(); + Type *ValTy = pickType(); // Do not store vectors of i1s because they are unsupported // by the codegen.