diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3497,7 +3497,7 @@ if (isa(V)) return UndefInt8; - const uint64_t Size = DL.getTypeStoreSize(V->getType()); + const uint64_t Size = DL.getTypeStoreSize(V->getType()).getKnownMinSize(); if (!Size) return UndefInt8; @@ -3816,7 +3816,7 @@ Array = nullptr; } else { const DataLayout &DL = GV->getParent()->getDataLayout(); - uint64_t SizeInBytes = DL.getTypeStoreSize(GVTy); + uint64_t SizeInBytes = DL.getTypeStoreSize(GVTy).getFixedSize(); uint64_t Length = SizeInBytes / (ElementSize / 8); if (Length <= Offset) return false; diff --git a/llvm/test/Transforms/MemCpyOpt/vscale.ll b/llvm/test/Transforms/MemCpyOpt/vscale.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/MemCpyOpt/vscale.ll @@ -0,0 +1,18 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -S -memcpyopt | FileCheck %s + +; Check that this test doesn't cause compier warning +; warning: Compiler has made implicit assumption that TypeSize is not scalable. This may or may not lead to broken code. + +define @test_isBytewiseValue( %z) { +; CHECK-LABEL: @test_isBytewiseValue( +; CHECK-NEXT: [[A:%.*]] = alloca +; CHECK-NEXT: store [[Z:%.*]], * [[A]] +; CHECK-NEXT: [[LOAD:%.*]] = load , * [[A]] +; CHECK-NEXT: ret [[LOAD]] +; + %a = alloca + store %z, * %a + %load = load , * %a + ret %load +}