diff options
| author | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:31:13 +0000 |
|---|---|---|
| committer | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:31:13 +0000 |
| commit | 33031926b66b80a593856d89e3c05b509ae95c68 (patch) | |
| tree | 1d3f9948ce18c8eb55ccec85786c75887a4ec5ba /llvm/unittests/FuzzMutate | |
| parent | 65902db27992be02f81efc47051f4253dffce47b (diff) | |
| download | bcm5719-llvm-33031926b66b80a593856d89e3c05b509ae95c68.tar.gz bcm5719-llvm-33031926b66b80a593856d89e3c05b509ae95c68.zip | |
[FuzzMutate] Correctly handle vector types in the insertvalue operation
Differential Revision: https://reviews.llvm.org/D40397
llvm-svn: 319442
Diffstat (limited to 'llvm/unittests/FuzzMutate')
| -rw-r--r-- | llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp index 5e1b338a95f..7d69bda91cc 100644 --- a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp +++ b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp @@ -164,4 +164,40 @@ TEST(RandomIRBuilderTest, ShuffleVectorSink) { } } +TEST(RandomIRBuilderTest, InsertValueArray) { + // Check that we can generate insertvalue for the vector operations + + LLVMContext Ctx; + const char *SourceCode = + "define void @test() {\n" + " %A = alloca [8 x i32]\n" + " %L = load [8 x i32], [8 x i32]* %A" + " ret void\n" + "}"; + auto M = parseAssembly(SourceCode, Ctx); + + fuzzerop::OpDescriptor Descr = fuzzerop::insertValueDescriptor(1); + + std::vector<Type *> Types = + {Type::getInt8Ty(Ctx), Type::getInt32Ty(Ctx), Type::getInt64Ty(Ctx)}; + RandomIRBuilder IB(Seed, Types); + + // Get first basic block of the first function + Function &F = *M->begin(); + BasicBlock &BB = *F.begin(); + + // Pick first source + Instruction *Source = &*std::next(BB.begin()); + ASSERT_TRUE(Descr.SourcePreds[0].matches({}, Source)); + + SmallVector<Value *, 2> Srcs(2); + + // Check that we can always pick the last two operands. + for (int i = 0; i < 10; ++i) { + Srcs[0] = Source; + Srcs[1] = IB.findOrCreateSource(BB, {Source}, Srcs, Descr.SourcePreds[1]); + IB.findOrCreateSource(BB, {}, Srcs, Descr.SourcePreds[2]); + } +} + } |

