[TTI] Make assertion compatible with opaque pointers
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Jun 2021 10:21:12 +0000 (12:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Jun 2021 10:21:54 +0000 (12:21 +0200)
Dropping the TODO here because it applies to all uses of this method.

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

index dfedba6..2e9e27f 100644 (file)
@@ -857,9 +857,8 @@ public:
              ArrayRef<const Value *> Operands,
              TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
     assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
-    // TODO: will remove this when pointers have an opaque type.
-    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
-               PointeeType &&
+    assert(cast<PointerType>(Ptr->getType()->getScalarType())
+               ->isOpaqueOrPointeeTypeMatches(PointeeType) &&
            "explicit pointee type doesn't match operand's pointee type");
     auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
     bool HasBaseReg = (BaseGV == nullptr);