diff options
author | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:29:16 +0000 |
---|---|---|
committer | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:29:16 +0000 |
commit | 65902db27992be02f81efc47051f4253dffce47b (patch) | |
tree | 8d73368501d83b6cac14bc7e3af9a01fbe867ed2 /llvm/unittests/FuzzMutate | |
parent | 48147d012b56cf56d909830c59164774921d90f4 (diff) | |
download | bcm5719-llvm-65902db27992be02f81efc47051f4253dffce47b.tar.gz bcm5719-llvm-65902db27992be02f81efc47051f4253dffce47b.zip |
[FuzzMutate] Don't use index operands as sinks
Differential Revision: https://reviews.llvm.org/D40396
llvm-svn: 319441
Diffstat (limited to 'llvm/unittests/FuzzMutate')
-rw-r--r-- | llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp index 55b75cd2653..5e1b338a95f 100644 --- a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp +++ b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp @@ -130,4 +130,38 @@ TEST(RandomIRBuilderTest, InsertValueIndexes) { } } +TEST(RandomIRBuilderTest, ShuffleVectorSink) { + // Check that we will never use shuffle vector mask as a sink form the + // unrelated operation. + + LLVMContext Ctx; + const char *SourceCode = + "define void @test(<4 x i32> %a) {\n" + " %S1 = shufflevector <4 x i32> %a, <4 x i32> %a, <4 x i32> undef\n" + " %S2 = shufflevector <4 x i32> %a, <4 x i32> %a, <4 x i32> undef\n" + " ret void\n" + "}"; + auto M = parseAssembly(SourceCode, Ctx); + + fuzzerop::OpDescriptor IVDescr = fuzzerop::insertValueDescriptor(1); + + RandomIRBuilder IB(Seed, {}); + + // Get first basic block of the first function + Function &F = *M->begin(); + BasicBlock &BB = *F.begin(); + + // Source is %S1 + Instruction *Source = &*BB.begin(); + // Sink is %S2 + SmallVector<Instruction *, 1> Sinks = {&*std::next(BB.begin())}; + + // Loop to account for random decisions + for (int i = 0; i < 10; ++i) { + // Try to connect S1 to S2. We should always create new sink. + IB.connectToSink(BB, Sinks, Source); + ASSERT_TRUE(!verifyModule(*M, &errs())); + } +} + } |