: Value(Raw > MaxValue ? Unknown : Raw) {}
static LocationSize precise(uint64_t Value) { return LocationSize(Value); }
+ static LocationSize precise(TypeSize Value) {
+ if (Value.isScalable())
+ return unknown();
+ return precise(Value.getFixedSize());
+ }
static LocationSize upperBound(uint64_t Value) {
// You can't go lower than 0, so give a precise result.
return unknown();
return LocationSize(Value | ImpreciseBit, Direct);
}
+ static LocationSize upperBound(TypeSize Value) {
+ if (Value.isScalable())
+ return unknown();
+ return upperBound(Value.getFixedSize());
+ }
constexpr static LocationSize unknown() {
return LocationSize(Unknown, Direct);
if (!I.getAllocatedType()->isSized())
return unknown();
+ if (I.getAllocatedType()->isVectorTy() &&
+ I.getAllocatedType()->getVectorIsScalable())
+ return unknown();
+
APInt Size(IntTyBits, DL.getTypeAllocSize(I.getAllocatedType()));
if (!I.isArrayAllocation())
return std::make_pair(align(Size, I.getAlignment()), Zero);
if (DerefBytes == 0 && (A->hasByValAttr() || A->hasStructRetAttr())) {
Type *PT = cast<PointerType>(A->getType())->getElementType();
if (PT->isSized())
- DerefBytes = DL.getTypeStoreSize(PT);
+ DerefBytes = DL.getTypeStoreSize(PT).getKnownMinSize();
}
if (DerefBytes == 0) {
DerefBytes = A->getDereferenceableOrNullBytes();
}
} else if (auto *AI = dyn_cast<AllocaInst>(this)) {
if (!AI->isArrayAllocation()) {
- DerefBytes = DL.getTypeStoreSize(AI->getAllocatedType());
+ DerefBytes =
+ DL.getTypeStoreSize(AI->getAllocatedType()).getKnownMinSize();
CanBeNull = false;
}
} else if (auto *GV = dyn_cast<GlobalVariable>(this)) {
if (GV->getValueType()->isSized() && !GV->hasExternalWeakLinkage()) {
// TODO: Don't outright reject hasExternalWeakLinkage but set the
// CanBeNull flag.
- DerefBytes = DL.getTypeStoreSize(GV->getValueType());
+ DerefBytes = DL.getTypeStoreSize(GV->getValueType()).getFixedSize();
CanBeNull = false;
}
}
--- /dev/null
+; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s
+; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>' -verify-memoryssa -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK-LABEL: define <vscale x 4 x i32> @f(
+; CHECK: 1 = MemoryDef(liveOnEntry)
+; CHECK: MemoryUse(1) MustAlias
+define <vscale x 4 x i32> @f(<vscale x 4 x i32> %z) {
+ %a = alloca <vscale x 4 x i32>
+ store <vscale x 4 x i32> %z, <vscale x 4 x i32>* %a
+ %zz = load <vscale x 4 x i32>, <vscale x 4 x i32>* %a
+ ret <vscale x 4 x i32> %zz
+}
+
+; CHECK-LABEL: define i32 @g(
+; CHECK: 1 = MemoryDef(liveOnEntry)
+; CHECK: MemoryUse(1) MayAlias
+declare i32* @gg(<vscale x 4 x i32>* %a)
+define i32 @g(i32 %z, i32 *%bb) {
+ %a = alloca <vscale x 4 x i32>
+ %aa = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i32 0, i32 0
+ store i32 %z, i32* %aa
+ %bbb = call i32* @gg(<vscale x 4 x i32>* %a) readnone
+ %zz = load i32, i32* %bbb
+ ret i32 %zz
+}