[PATCH] D64052: Return Undef from isBytewiseValue for empty arrays or structs
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 18:07:42 PDT 2019
vitalybuka created this revision.
vitalybuka added reviewers: pcc, eugenis.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
vitalybuka added a parent revision: D64031: isBytewiseValue checks ConstantVector element by element.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64052
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/unittests/Analysis/ValueTrackingTest.cpp
Index: llvm/unittests/Analysis/ValueTrackingTest.cpp
===================================================================
--- llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -798,7 +798,7 @@
"i16* inttoptr (i96 -1 to i16*)",
},
{
- "i8 0",
+ "i8 undef",
"[0 x i8] zeroinitializer",
},
{
@@ -880,7 +880,7 @@
"[2 x i16] [i16 -21836, i16 -21846]]",
},
{
- "i8 0",
+ "i8 undef",
"{ } zeroinitializer",
},
{
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -3179,6 +3179,13 @@
if (isa<UndefValue>(V))
return UndefInt8;
+ if (auto *T = dyn_cast<SequentialType>(V->getType()))
+ if (!T->getNumElements())
+ return UndefInt8;
+ if (auto *T = dyn_cast<StructType>(V->getType()))
+ if (!T->getNumElements())
+ return UndefInt8;
+
Constant *C = dyn_cast<Constant>(V);
if (!C) {
// Conceptually, we could handle things like:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64052.207449.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190702/41aa097c/attachment.bin>
More information about the llvm-commits
mailing list