[clang] 2c44168 - [Clang] Remove typed pointer consistency assertions (NFC)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 00:45:51 PDT 2023
Author: Nikita Popov
Date: 2023-06-09T09:45:43+02:00
New Revision: 2c44168381f0b06eb629cd093510a9fca6913066
URL: https://github.com/llvm/llvm-project/commit/2c44168381f0b06eb629cd093510a9fca6913066
DIFF: https://github.com/llvm/llvm-project/commit/2c44168381f0b06eb629cd093510a9fca6913066.diff
LOG: [Clang] Remove typed pointer consistency assertions (NFC)
These are no-ops with opaque pointers.
Added:
Modified:
clang/lib/CodeGen/Address.h
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGValue.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a45df7f8497e4..e020d95344ade 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -41,9 +41,6 @@ class Address {
ElementType(ElementType), Alignment(Alignment) {
assert(Pointer != nullptr && "Pointer cannot be null");
assert(ElementType != nullptr && "Element type cannot be null");
- assert(llvm::cast<llvm::PointerType>(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 f18d8be5ecd9d..902fd94570837 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -89,8 +89,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
CharUnits Align,
const llvm::Twine &Name = "") {
- assert(llvm::cast<llvm::PointerType>(Addr->getType())
- ->isOpaqueOrPointeeTypeMatches(Ty));
return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
}
@@ -120,15 +118,11 @@ class CGBuilderTy : public CGBuilderBaseTy {
/// Emit a load from an i1 flag variable.
llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,
const llvm::Twine &Name = "") {
- assert(llvm::cast<llvm::PointerType>(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<llvm::PointerType>(Addr->getType())
- ->isOpaqueOrPointeeTypeMatches(getInt1Ty()));
return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One());
}
@@ -157,9 +151,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
using CGBuilderBaseTy::CreateAddrSpaceCast;
Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
const llvm::Twine &Name = "") {
- assert(cast<llvm::PointerType>(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 eb45e82fe8256..d39131828c066 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<FunctionDecl>(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<llvm::PointerType>(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 bbbe4749cdfb0..4c5d14e1e7028 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<llvm::PointerType>(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 cd2e9e42a9786..1e6f67250583d 100644
--- a/clang/lib/CodeGen/CGValue.h
+++ b/clang/lib/CodeGen/CGValue.h
@@ -241,9 +241,7 @@ class LValue {
if (isGlobalReg())
assert(ElementType == nullptr && "Global reg does not store elem type");
else
- assert(llvm::cast<llvm::PointerType>(V->getType())
- ->isOpaqueOrPointeeTypeMatches(ElementType) &&
- "Pointer element type mismatch");
+ assert(ElementType != nullptr && "Must have elem type");
this->Type = Type;
this->Quals = Quals;
More information about the cfe-commits
mailing list