Return Undef from isBytewiseValue for empty arrays or structs

Reviewers: pcc, eugenis

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64052

llvm-svn: 365864
This commit is contained in:
Vitaly Buka 2019-07-12 02:23:07 +00:00
parent 8bd441af8b
commit 52096ee9a9
2 changed files with 8 additions and 4 deletions

View File

@ -3178,6 +3178,10 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
if (isa<UndefValue>(V))
return UndefInt8;
const uint64_t Size = DL.getTypeStoreSize(V->getType());
if (!Size)
return UndefInt8;
Constant *C = dyn_cast<Constant>(V);
if (!C) {
// Conceptually, we could handle things like:

View File

@ -810,7 +810,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"i16* inttoptr (i96 -1 to i16*)",
},
{
"i8 0",
"i8 undef",
"[0 x i8] zeroinitializer",
},
{
@ -818,7 +818,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"[0 x i8] undef",
},
{
"i8 0",
"i8 undef",
"[5 x [0 x i8]] zeroinitializer",
},
{
@ -900,7 +900,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"[2 x i16] [i16 -21836, i16 -21846]]",
},
{
"i8 0",
"i8 undef",
"{ } zeroinitializer",
},
{
@ -908,7 +908,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"{ } undef",
},
{
"i8 0",
"i8 undef",
"{ {}, {} } zeroinitializer",
},
{