[PATCH] D76454: [ValueTracking] Fix usage of DataLayout::getTypeStoreSize()
Huihui Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 19 14:15:17 PDT 2020
huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, apazos, reames.
huihuiz added a project: LLVM.
Herald added a subscriber: hiraditya.
DataLayout::getTypeStoreSize() returns TypeSize.
For cases where it can not be scalable vector (GlobalVariable),
explicitly call TypeSize::getFixedSize().
For cases where scalable property doesn't matter (check for zero-sized),
explicitly call TypeSize::getKnownMinSize(), to avoid implicit type
conversion to uint64_t, which is invalid for scalable vector.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76454
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/MemCpyOpt/vscale.ll
Index: llvm/test/Transforms/MemCpyOpt/vscale.ll
===================================================================
--- /dev/null
+++ 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 <vscale x 4 x i32> @test_isBytewiseValue(<vscale x 4 x i32> %z) {
+; CHECK-LABEL: @test_isBytewiseValue(
+; CHECK-NEXT: [[A:%.*]] = alloca <vscale x 4 x i32>
+; CHECK-NEXT: store <vscale x 4 x i32> [[Z:%.*]], <vscale x 4 x i32>* [[A]]
+; CHECK-NEXT: [[LOAD:%.*]] = load <vscale x 4 x i32>, <vscale x 4 x i32>* [[A]]
+; CHECK-NEXT: ret <vscale x 4 x i32> [[LOAD]]
+;
+ %a = alloca <vscale x 4 x i32>
+ store <vscale x 4 x i32> %z, <vscale x 4 x i32>* %a
+ %load = load <vscale x 4 x i32>, <vscale x 4 x i32>* %a
+ ret <vscale x 4 x i32> %load
+}
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -3497,7 +3497,7 @@
if (isa<UndefValue>(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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76454.251468.patch
Type: text/x-patch
Size: 1867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200319/eacf1bbc/attachment.bin>
More information about the llvm-commits
mailing list