From 2c44168381f0b06eb629cd093510a9fca6913066 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 9 Jun 2023 09:32:27 +0200 Subject: [PATCH] [Clang] Remove typed pointer consistency assertions (NFC) These are no-ops with opaque pointers. --- clang/lib/CodeGen/Address.h | 3 --- clang/lib/CodeGen/CGBuilder.h | 9 --------- clang/lib/CodeGen/CGCall.cpp | 19 ------------------- clang/lib/CodeGen/CGDecl.cpp | 3 --- clang/lib/CodeGen/CGValue.h | 4 +--- 5 files changed, 1 insertion(+), 37 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a45df7f..e020d95 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -41,9 +41,6 @@ public: ElementType(ElementType), Alignment(Alignment) { assert(Pointer != nullptr && "Pointer cannot be null"); assert(ElementType != nullptr && "Element type cannot be null"); - assert(llvm::cast(Pointer->getType()) - ->isOpaqueOrPointeeTypeMatches(ElementType) && - "Incorrect pointer element type"); } static Address invalid() { return Address(nullptr); } diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h index f18d8be5..902fd94 100644 --- a/clang/lib/CodeGen/CGBuilder.h +++ b/clang/lib/CodeGen/CGBuilder.h @@ -89,8 +89,6 @@ public: llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name = "") { - assert(llvm::cast(Addr->getType()) - ->isOpaqueOrPointeeTypeMatches(Ty)); return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name); } @@ -120,15 +118,11 @@ public: /// Emit a load from an i1 flag variable. llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name = "") { - assert(llvm::cast(Addr->getType()) - ->isOpaqueOrPointeeTypeMatches(getInt1Ty())); return CreateAlignedLoad(getInt1Ty(), Addr, CharUnits::One(), Name); } /// Emit a store to an i1 flag variable. llvm::StoreInst *CreateFlagStore(bool Value, llvm::Value *Addr) { - assert(llvm::cast(Addr->getType()) - ->isOpaqueOrPointeeTypeMatches(getInt1Ty())); return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One()); } @@ -157,9 +151,6 @@ public: using CGBuilderBaseTy::CreateAddrSpaceCast; Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name = "") { - assert(cast(Ty)->isOpaqueOrPointeeTypeMatches( - Addr.getElementType()) && - "Should not change the element type"); return Addr.withPointer(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name), Addr.isKnownNonNull()); } diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index eb45e82..d391318 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -4912,25 +4912,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, CGM, Loc, dyn_cast_or_null(CurCodeDecl), FD, CallArgs); } -#ifndef NDEBUG - if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) { - // For an inalloca varargs function, we don't expect CallInfo to match the - // function pointer's type, because the inalloca struct a will have extra - // fields in it for the varargs parameters. Code later in this function - // bitcasts the function pointer to the type derived from CallInfo. - // - // In other cases, we assert that the types match up (until pointers stop - // having pointee types). - if (Callee.isVirtual()) - assert(IRFuncTy == Callee.getVirtualFunctionType()); - else { - llvm::PointerType *PtrTy = - llvm::cast(Callee.getFunctionPointer()->getType()); - assert(PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy)); - } - } -#endif - // 1. Set up the arguments. // If we're using inalloca, insert the allocation after the stack save. diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index bbbe474..4c5d14e 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1405,9 +1405,6 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions( else { // Create an artificial VarDecl to generate debug info for. IdentifierInfo *NameIdent = VLAExprNames[NameIdx++]; - assert(cast(VlaSize.NumElts->getType()) - ->isOpaqueOrPointeeTypeMatches(SizeTy) && - "Number of VLA elements must be SizeTy"); auto QT = getContext().getIntTypeForBitwidth( SizeTy->getScalarSizeInBits(), false); auto *ArtificialDecl = VarDecl::Create( diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index cd2e9e4..1e6f672 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/lib/CodeGen/CGValue.h @@ -241,9 +241,7 @@ private: if (isGlobalReg()) assert(ElementType == nullptr && "Global reg does not store elem type"); else - assert(llvm::cast(V->getType()) - ->isOpaqueOrPointeeTypeMatches(ElementType) && - "Pointer element type mismatch"); + assert(ElementType != nullptr && "Must have elem type"); this->Type = Type; this->Quals = Quals; -- 2.7.4