summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorIgor Laevsky <igmyrj@gmail.com>2017-12-13 11:49:04 +0000
committerIgor Laevsky <igmyrj@gmail.com>2017-12-13 11:49:04 +0000
commita3d1ab818634c34c95092ed1f691d8b20578c867 (patch)
tree2599c05028b11a49f87a6e3d3d07db0e512b5175 /unittests
parent95edead4fe428299acc43c01526c81800aeaad4a (diff)
[FuzzMutate] Only generate loads and stores to the first class sized types
Differential Revision: https://reviews.llvm.org/D41109 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320573 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/FuzzMutate/RandomIRBuilderTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/FuzzMutate/RandomIRBuilderTest.cpp b/unittests/FuzzMutate/RandomIRBuilderTest.cpp
index cd0b96bf859..b60da6cbf9f 100644
--- a/unittests/FuzzMutate/RandomIRBuilderTest.cpp
+++ b/unittests/FuzzMutate/RandomIRBuilderTest.cpp
@@ -236,4 +236,34 @@ TEST(RandomIRBuilderTest, Invokes) {
}
}
+TEST(RandomIRBuilderTest, FirstClassTypes) {
+ // Check that we never insert new source as a load from non first class
+ // or unsized type.
+
+ LLVMContext Ctx;
+ const char *SourceCode = "%Opaque = type opaque\n"
+ "define void @test(i8* %ptr) {\n"
+ "entry:\n"
+ " %tmp = bitcast i8* %ptr to i32* (i32*)*\n"
+ " %tmp1 = bitcast i8* %ptr to %Opaque*\n"
+ " ret void\n"
+ "}";
+ auto M = parseAssembly(SourceCode, Ctx);
+
+ std::vector<Type *> Types = {Type::getInt8Ty(Ctx)};
+ RandomIRBuilder IB(Seed, Types);
+
+ Function &F = *M->getFunction("test");
+ BasicBlock &BB = *F.begin();
+ // Non first class type
+ Instruction *FuncPtr = &*BB.begin();
+ // Unsized type
+ Instruction *OpaquePtr = &*std::next(BB.begin());
+
+ for (int i = 0; i < 10; ++i) {
+ Value *V = IB.findOrCreateSource(BB, {FuncPtr, OpaquePtr});
+ ASSERT_FALSE(isa<LoadInst>(V));
+ }
+}
+
}