Skip to content

Commit 2c44168

Browse files
committed
[Clang] Remove typed pointer consistency assertions (NFC)
These are no-ops with opaque pointers.
1 parent a5fc989 commit 2c44168

File tree

5 files changed

+1
-37
lines changed

5 files changed

+1
-37
lines changed

clang/lib/CodeGen/Address.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ class Address {
4141
ElementType(ElementType), Alignment(Alignment) {
4242
assert(Pointer != nullptr && "Pointer cannot be null");
4343
assert(ElementType != nullptr && "Element type cannot be null");
44-
assert(llvm::cast<llvm::PointerType>(Pointer->getType())
45-
->isOpaqueOrPointeeTypeMatches(ElementType) &&
46-
"Incorrect pointer element type");
4744
}
4845

4946
static Address invalid() { return Address(nullptr); }

clang/lib/CodeGen/CGBuilder.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
8989
llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
9090
CharUnits Align,
9191
const llvm::Twine &Name = "") {
92-
assert(llvm::cast<llvm::PointerType>(Addr->getType())
93-
->isOpaqueOrPointeeTypeMatches(Ty));
9492
return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
9593
}
9694

@@ -120,15 +118,11 @@ class CGBuilderTy : public CGBuilderBaseTy {
120118
/// Emit a load from an i1 flag variable.
121119
llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,
122120
const llvm::Twine &Name = "") {
123-
assert(llvm::cast<llvm::PointerType>(Addr->getType())
124-
->isOpaqueOrPointeeTypeMatches(getInt1Ty()));
125121
return CreateAlignedLoad(getInt1Ty(), Addr, CharUnits::One(), Name);
126122
}
127123

128124
/// Emit a store to an i1 flag variable.
129125
llvm::StoreInst *CreateFlagStore(bool Value, llvm::Value *Addr) {
130-
assert(llvm::cast<llvm::PointerType>(Addr->getType())
131-
->isOpaqueOrPointeeTypeMatches(getInt1Ty()));
132126
return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One());
133127
}
134128

@@ -157,9 +151,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
157151
using CGBuilderBaseTy::CreateAddrSpaceCast;
158152
Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
159153
const llvm::Twine &Name = "") {
160-
assert(cast<llvm::PointerType>(Ty)->isOpaqueOrPointeeTypeMatches(
161-
Addr.getElementType()) &&
162-
"Should not change the element type");
163154
return Addr.withPointer(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
164155
Addr.isKnownNonNull());
165156
}

clang/lib/CodeGen/CGCall.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4912,25 +4912,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
49124912
CGM, Loc, dyn_cast_or_null<FunctionDecl>(CurCodeDecl), FD, CallArgs);
49134913
}
49144914

4915-
#ifndef NDEBUG
4916-
if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
4917-
// For an inalloca varargs function, we don't expect CallInfo to match the
4918-
// function pointer's type, because the inalloca struct a will have extra
4919-
// fields in it for the varargs parameters. Code later in this function
4920-
// bitcasts the function pointer to the type derived from CallInfo.
4921-
//
4922-
// In other cases, we assert that the types match up (until pointers stop
4923-
// having pointee types).
4924-
if (Callee.isVirtual())
4925-
assert(IRFuncTy == Callee.getVirtualFunctionType());
4926-
else {
4927-
llvm::PointerType *PtrTy =
4928-
llvm::cast<llvm::PointerType>(Callee.getFunctionPointer()->getType());
4929-
assert(PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy));
4930-
}
4931-
}
4932-
#endif
4933-
49344915
// 1. Set up the arguments.
49354916

49364917
// If we're using inalloca, insert the allocation after the stack save.

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,9 +1405,6 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
14051405
else {
14061406
// Create an artificial VarDecl to generate debug info for.
14071407
IdentifierInfo *NameIdent = VLAExprNames[NameIdx++];
1408-
assert(cast<llvm::PointerType>(VlaSize.NumElts->getType())
1409-
->isOpaqueOrPointeeTypeMatches(SizeTy) &&
1410-
"Number of VLA elements must be SizeTy");
14111408
auto QT = getContext().getIntTypeForBitwidth(
14121409
SizeTy->getScalarSizeInBits(), false);
14131410
auto *ArtificialDecl = VarDecl::Create(

clang/lib/CodeGen/CGValue.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ class LValue {
241241
if (isGlobalReg())
242242
assert(ElementType == nullptr && "Global reg does not store elem type");
243243
else
244-
assert(llvm::cast<llvm::PointerType>(V->getType())
245-
->isOpaqueOrPointeeTypeMatches(ElementType) &&
246-
"Pointer element type mismatch");
244+
assert(ElementType != nullptr && "Must have elem type");
247245

248246
this->Type = Type;
249247
this->Quals = Quals;

0 commit comments

Comments
 (0)