[PATCH] D41110: [FuzzMutate] Avoid zero sized aggregates
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 03:48:27 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320572: [FuzzMutate] Avoid zero sized aggregates (authored by igor.laevsky, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D41110
Files:
llvm/trunk/include/llvm/FuzzMutate/OpDescriptor.h
llvm/trunk/unittests/FuzzMutate/OperationsTest.cpp
Index: llvm/trunk/unittests/FuzzMutate/OperationsTest.cpp
===================================================================
--- llvm/trunk/unittests/FuzzMutate/OperationsTest.cpp
+++ llvm/trunk/unittests/FuzzMutate/OperationsTest.cpp
@@ -336,6 +336,7 @@
Type *StructTy = StructType::create(Ctx, {Int8PtrTy, Int32Ty});
Type *OpaqueTy = StructType::create(Ctx, "OpaqueStruct");
+ Type *ZeroSizedArrayTy = ArrayType::get(Int64Ty, 0);
Type *ArrayTy = ArrayType::get(Int64Ty, 4);
Type *VectorTy = VectorType::get(Int32Ty, 2);
@@ -346,17 +347,22 @@
Constant *SVal = UndefValue::get(StructTy);
Constant *OVal = UndefValue::get(OpaqueTy);
Constant *AVal = UndefValue::get(ArrayTy);
+ Constant *ZAVal = UndefValue::get(ZeroSizedArrayTy);
Constant *VVal = UndefValue::get(VectorTy);
EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, SVal));
- EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, OVal));
+ EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, OVal));
EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, AVal));
EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, VVal));
EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, SVal));
- EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, OVal));
+ EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, OVal));
EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, AVal));
EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, VVal));
+ // Don't consider zero sized arrays as viable sources
+ EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, ZAVal));
+ EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, ZAVal));
+
// Make sure we're range checking appropriately.
EXPECT_TRUE(
EVOp.SourcePreds[1].matches({SVal}, ConstantInt::get(Int32Ty, 0)));
Index: llvm/trunk/include/llvm/FuzzMutate/OpDescriptor.h
===================================================================
--- llvm/trunk/include/llvm/FuzzMutate/OpDescriptor.h
+++ llvm/trunk/include/llvm/FuzzMutate/OpDescriptor.h
@@ -160,6 +160,14 @@
static inline SourcePred anyAggregateType() {
auto Pred = [](ArrayRef<Value *>, const Value *V) {
+ // We can't index zero sized arrays.
+ if (isa<ArrayType>(V->getType()))
+ return V->getType()->getArrayNumElements() > 0;
+
+ // Structs can also be zero sized. I.e opaque types.
+ if (isa<StructType>(V->getType()))
+ return V->getType()->getStructNumElements() > 0;
+
return V->getType()->isAggregateType();
};
// TODO: For now we only find aggregates in BaseTypes. It might be better to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41110.126720.patch
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/fccf98b6/attachment.bin>
More information about the llvm-commits
mailing list