Skip to content

Commit 9cf5254

Browse files
committed
[llvm] Remove some uses of isOpaqueOrPointeeTypeEquals() (NFC)
1 parent 2c65118 commit 9cf5254

File tree

12 files changed

+3
-66
lines changed

12 files changed

+3
-66
lines changed

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
990990
ArrayRef<const Value *> Operands, Type *AccessType,
991991
TTI::TargetCostKind CostKind) {
992992
assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
993-
assert(cast<PointerType>(Ptr->getType()->getScalarType())
994-
->isOpaqueOrPointeeTypeMatches(PointeeType) &&
995-
"explicit pointee type doesn't match operand's pointee type");
996993
auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
997994
bool HasBaseReg = (BaseGV == nullptr);
998995

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,10 +1188,7 @@ class OpenMPIRBuilder {
11881188
AtomicReductionGenTy AtomicReductionGen)
11891189
: ElementType(ElementType), Variable(Variable),
11901190
PrivateVariable(PrivateVariable), ReductionGen(ReductionGen),
1191-
AtomicReductionGen(AtomicReductionGen) {
1192-
assert(cast<PointerType>(Variable->getType())
1193-
->isOpaqueOrPointeeTypeMatches(ElementType) && "Invalid elem type");
1194-
}
1191+
AtomicReductionGen(AtomicReductionGen) {}
11951192

11961193
/// Reduction element type, must match pointee type of variable.
11971194
Type *ElementType;

llvm/include/llvm/IR/InstrTypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,6 @@ class CallBase : public Instruction {
14611461
/// type.
14621462
void setCalledFunction(FunctionType *FTy, Value *Fn) {
14631463
this->FTy = FTy;
1464-
assert(cast<PointerType>(Fn->getType())->isOpaqueOrPointeeTypeMatches(FTy));
14651464
// This function doesn't mutate the return type, only the function
14661465
// type. Seems broken, but I'm just gonna stick an assert in for now.
14671466
assert(getType() == FTy->getReturnType());

llvm/include/llvm/IR/Instructions.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,6 @@ class GetElementPtrInst : public Instruction {
969969
Instruction *InsertBefore = nullptr) {
970970
unsigned Values = 1 + unsigned(IdxList.size());
971971
assert(PointeeType && "Must specify element type");
972-
assert(cast<PointerType>(Ptr->getType()->getScalarType())
973-
->isOpaqueOrPointeeTypeMatches(PointeeType));
974972
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
975973
NameStr, InsertBefore);
976974
}
@@ -981,8 +979,6 @@ class GetElementPtrInst : public Instruction {
981979
BasicBlock *InsertAtEnd) {
982980
unsigned Values = 1 + unsigned(IdxList.size());
983981
assert(PointeeType && "Must specify element type");
984-
assert(cast<PointerType>(Ptr->getType()->getScalarType())
985-
->isOpaqueOrPointeeTypeMatches(PointeeType));
986982
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
987983
NameStr, InsertAtEnd);
988984
}
@@ -1018,8 +1014,6 @@ class GetElementPtrInst : public Instruction {
10181014
void setResultElementType(Type *Ty) { ResultElementType = Ty; }
10191015

10201016
Type *getResultElementType() const {
1021-
assert(cast<PointerType>(getType()->getScalarType())
1022-
->isOpaqueOrPointeeTypeMatches(ResultElementType));
10231017
return ResultElementType;
10241018
}
10251019

@@ -1165,8 +1159,6 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
11651159
Values, InsertBefore),
11661160
SourceElementType(PointeeType),
11671161
ResultElementType(getIndexedType(PointeeType, IdxList)) {
1168-
assert(cast<PointerType>(getType()->getScalarType())
1169-
->isOpaqueOrPointeeTypeMatches(ResultElementType));
11701162
init(Ptr, IdxList, NameStr);
11711163
}
11721164

@@ -1179,8 +1171,6 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
11791171
Values, InsertAtEnd),
11801172
SourceElementType(PointeeType),
11811173
ResultElementType(getIndexedType(PointeeType, IdxList)) {
1182-
assert(cast<PointerType>(getType()->getScalarType())
1183-
->isOpaqueOrPointeeTypeMatches(ResultElementType));
11841174
init(Ptr, IdxList, NameStr);
11851175
}
11861176

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,10 +1470,6 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
14701470
ScalarEvolution &SE, bool StrictCheck,
14711471
bool CheckType) {
14721472
assert(PtrA && PtrB && "Expected non-nullptr pointers.");
1473-
assert(cast<PointerType>(PtrA->getType())
1474-
->isOpaqueOrPointeeTypeMatches(ElemTyA) && "Wrong PtrA type");
1475-
assert(cast<PointerType>(PtrB->getType())
1476-
->isOpaqueOrPointeeTypeMatches(ElemTyB) && "Wrong PtrB type");
14771473

14781474
// Make sure that A and B are different pointers.
14791475
if (PtrA == PtrB)

llvm/lib/IR/Constants.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,6 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
23832383
PointerType *OrigPtrTy = cast<PointerType>(C->getType()->getScalarType());
23842384
assert(Ty && "Must specify element type");
23852385
assert(isSupportedGetElementPtr(Ty) && "Element type is unsupported!");
2386-
assert(OrigPtrTy->isOpaqueOrPointeeTypeMatches(Ty));
23872386

23882387
if (Constant *FC =
23892388
ConstantFoldGetElementPtr(Ty, C, InBounds, InRangeIndex, Idxs))

llvm/lib/IR/Instructions.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,6 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
15931593
Align Align, AtomicOrdering Order, SyncScope::ID SSID,
15941594
Instruction *InsertBef)
15951595
: UnaryInstruction(Ty, Load, Ptr, InsertBef) {
1596-
assert(cast<PointerType>(Ptr->getType())->isOpaqueOrPointeeTypeMatches(Ty));
15971596
setVolatile(isVolatile);
15981597
setAlignment(Align);
15991598
setAtomic(Order, SSID);
@@ -1605,7 +1604,6 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
16051604
Align Align, AtomicOrdering Order, SyncScope::ID SSID,
16061605
BasicBlock *InsertAE)
16071606
: UnaryInstruction(Ty, Load, Ptr, InsertAE) {
1608-
assert(cast<PointerType>(Ptr->getType())->isOpaqueOrPointeeTypeMatches(Ty));
16091607
setVolatile(isVolatile);
16101608
setAlignment(Align);
16111609
setAtomic(Order, SSID);
@@ -1621,9 +1619,6 @@ void StoreInst::AssertOK() {
16211619
assert(getOperand(0) && getOperand(1) && "Both operands must be non-null!");
16221620
assert(getOperand(1)->getType()->isPointerTy() &&
16231621
"Ptr must have pointer type!");
1624-
assert(cast<PointerType>(getOperand(1)->getType())
1625-
->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) &&
1626-
"Ptr must be a pointer to Val type!");
16271622
}
16281623

16291624
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
@@ -1703,12 +1698,6 @@ void AtomicCmpXchgInst::Init(Value *Ptr, Value *Cmp, Value *NewVal,
17031698
"All operands must be non-null!");
17041699
assert(getOperand(0)->getType()->isPointerTy() &&
17051700
"Ptr must have pointer type!");
1706-
assert(cast<PointerType>(getOperand(0)->getType())
1707-
->isOpaqueOrPointeeTypeMatches(getOperand(1)->getType()) &&
1708-
"Ptr must be a pointer to Cmp type!");
1709-
assert(cast<PointerType>(getOperand(0)->getType())
1710-
->isOpaqueOrPointeeTypeMatches(getOperand(2)->getType()) &&
1711-
"Ptr must be a pointer to NewVal type!");
17121701
assert(getOperand(1)->getType() == getOperand(2)->getType() &&
17131702
"Cmp type and NewVal type must be same!");
17141703
}
@@ -1761,9 +1750,6 @@ void AtomicRMWInst::Init(BinOp Operation, Value *Ptr, Value *Val,
17611750
"All operands must be non-null!");
17621751
assert(getOperand(0)->getType()->isPointerTy() &&
17631752
"Ptr must have pointer type!");
1764-
assert(cast<PointerType>(getOperand(0)->getType())
1765-
->isOpaqueOrPointeeTypeMatches(getOperand(1)->getType()) &&
1766-
"Ptr must be a pointer to Val type!");
17671753
assert(Ordering != AtomicOrdering::NotAtomic &&
17681754
"AtomicRMW instructions must be atomic!");
17691755
}

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -634,20 +634,13 @@ static void replaceSwiftErrorOps(Function &F, coro::Shape &Shape,
634634
return;
635635
Value *CachedSlot = nullptr;
636636
auto getSwiftErrorSlot = [&](Type *ValueTy) -> Value * {
637-
if (CachedSlot) {
638-
assert(cast<PointerType>(CachedSlot->getType())
639-
->isOpaqueOrPointeeTypeMatches(ValueTy) &&
640-
"multiple swifterror slots in function with different types");
637+
if (CachedSlot)
641638
return CachedSlot;
642-
}
643639

644640
// Check if the function has a swifterror argument.
645641
for (auto &Arg : F.args()) {
646642
if (Arg.isSwiftError()) {
647643
CachedSlot = &Arg;
648-
assert(cast<PointerType>(Arg.getType())
649-
->isOpaqueOrPointeeTypeMatches(ValueTy) &&
650-
"swifterror argument does not have expected type");
651644
return &Arg;
652645
}
653646
}

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,6 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
813813
int ThreadSanitizer::getMemoryAccessFuncIndex(Type *OrigTy, Value *Addr,
814814
const DataLayout &DL) {
815815
assert(OrigTy->isSized());
816-
assert(
817-
cast<PointerType>(Addr->getType())->isOpaqueOrPointeeTypeMatches(OrigTy));
818816
uint32_t TypeSize = DL.getTypeStoreSizeInBits(OrigTy);
819817
if (TypeSize != 8 && TypeSize != 16 &&
820818
TypeSize != 32 && TypeSize != 64 && TypeSize != 128) {

llvm/lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,7 @@ INITIALIZE_PASS_END(ScalarizerLegacyPass, "scalarizer",
374374
Scatterer::Scatterer(BasicBlock *bb, BasicBlock::iterator bbi, Value *v,
375375
const VectorSplit &VS, ValueVector *cachePtr)
376376
: BB(bb), BBI(bbi), V(v), VS(VS), CachePtr(cachePtr) {
377-
Type *Ty = V->getType();
378-
if (Ty->isPointerTy()) {
379-
assert(cast<PointerType>(Ty)->isOpaqueOrPointeeTypeMatches(VS.VecTy) &&
380-
"Pointer element type mismatch");
381-
IsPointer = true;
382-
} else {
383-
IsPointer = false;
384-
}
377+
IsPointer = V->getType()->isPointerTy();
385378
if (!CachePtr) {
386379
Tmp.resize(VS.NumFragments, nullptr);
387380
} else {

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,6 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
14801480
const Function *CalledFunc,
14811481
InlineFunctionInfo &IFI,
14821482
MaybeAlign ByValAlignment) {
1483-
assert(cast<PointerType>(Arg->getType())
1484-
->isOpaqueOrPointeeTypeMatches(ByValType));
14851483
Function *Caller = TheCall->getFunction();
14861484
const DataLayout &DL = Caller->getParent()->getDataLayout();
14871485

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,6 @@ TEST_F(OpenMPIRBuilderTest, ParallelForwardAsPointers) {
11801180

11811181
Type *Arg2Type = OutlinedFn->getArg(2)->getType();
11821182
EXPECT_TRUE(Arg2Type->isPointerTy());
1183-
EXPECT_TRUE(
1184-
cast<PointerType>(Arg2Type)->isOpaqueOrPointeeTypeMatches(ArgStructTy));
11851183
}
11861184

11871185
TEST_F(OpenMPIRBuilderTest, CanonicalLoopSimple) {
@@ -4795,20 +4793,13 @@ TEST_F(OpenMPIRBuilderTest, CreateMapperAllocas) {
47954793
EXPECT_TRUE(MapperAllocas.ArgsBase->getAllocatedType()
47964794
->getArrayElementType()
47974795
->isPointerTy());
4798-
EXPECT_TRUE(
4799-
cast<PointerType>(
4800-
MapperAllocas.ArgsBase->getAllocatedType()->getArrayElementType())
4801-
->isOpaqueOrPointeeTypeMatches(Builder.getInt8Ty()));
48024796

48034797
EXPECT_TRUE(MapperAllocas.Args->getAllocatedType()->isArrayTy());
48044798
ArrType = dyn_cast<ArrayType>(MapperAllocas.Args->getAllocatedType());
48054799
EXPECT_EQ(ArrType->getNumElements(), TotalNbOperand);
48064800
EXPECT_TRUE(MapperAllocas.Args->getAllocatedType()
48074801
->getArrayElementType()
48084802
->isPointerTy());
4809-
EXPECT_TRUE(cast<PointerType>(
4810-
MapperAllocas.Args->getAllocatedType()->getArrayElementType())
4811-
->isOpaqueOrPointeeTypeMatches(Builder.getInt8Ty()));
48124803

48134804
EXPECT_TRUE(MapperAllocas.ArgSizes->getAllocatedType()->isArrayTy());
48144805
ArrType = dyn_cast<ArrayType>(MapperAllocas.ArgSizes->getAllocatedType());

0 commit comments

Comments
 (0)