llvm.org GIT mirror llvm / 683cf0f
Add bitcode test to verify functions can be materialized out of order. Summary: Adds test to check that when getLazyBitcodeModule is called: 1) Functions are not materailzed by default. 2) Only the requested function gets materialized (if no block addresses are used). Reviewers: jvoung, rafael Reviewed By: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8907 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236611 91177308-0d34-0410-b5e6-96231b3b80d8 Derek Schuff 4 years ago
1 changed file(s) with 64 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8181 EXPECT_FALSE(verifyModule(*M, &dbgs()));
8282 }
8383
84 // Tests that lazy evaluation can parse functions out of order.
85 TEST(BitReaderTest, MaterializeFunctionsOutOfOrder) {
86 SmallString<1024> Mem;
87 LLVMContext Context;
88 std::unique_ptr M = getLazyModuleFromAssembly(
89 Context, Mem, "define void @f() {\n"
90 " unreachable\n"
91 "}\n"
92 "define void @g() {\n"
93 " unreachable\n"
94 "}\n"
95 "define void @h() {\n"
96 " unreachable\n"
97 "}\n"
98 "define void @j() {\n"
99 " unreachable\n"
100 "}\n");
101 EXPECT_FALSE(verifyModule(*M, &dbgs()));
102
103 Function *F = M->getFunction("f");
104 Function *G = M->getFunction("g");
105 Function *H = M->getFunction("h");
106 Function *J = M->getFunction("j");
107
108 // Initially all functions are not materialized (no basic blocks).
109 EXPECT_TRUE(F->empty());
110 EXPECT_TRUE(G->empty());
111 EXPECT_TRUE(H->empty());
112 EXPECT_TRUE(J->empty());
113 EXPECT_FALSE(verifyModule(*M, &dbgs()));
114
115 // Materialize h.
116 H->materialize();
117 EXPECT_TRUE(F->empty());
118 EXPECT_TRUE(G->empty());
119 EXPECT_FALSE(H->empty());
120 EXPECT_TRUE(J->empty());
121 EXPECT_FALSE(verifyModule(*M, &dbgs()));
122
123 // Materialize g.
124 G->materialize();
125 EXPECT_TRUE(F->empty());
126 EXPECT_FALSE(G->empty());
127 EXPECT_FALSE(H->empty());
128 EXPECT_TRUE(J->empty());
129 EXPECT_FALSE(verifyModule(*M, &dbgs()));
130
131 // Materialize j.
132 J->materialize();
133 EXPECT_TRUE(F->empty());
134 EXPECT_FALSE(G->empty());
135 EXPECT_FALSE(H->empty());
136 EXPECT_FALSE(J->empty());
137 EXPECT_FALSE(verifyModule(*M, &dbgs()));
138
139 // Materialize f.
140 F->materialize();
141 EXPECT_FALSE(F->empty());
142 EXPECT_FALSE(G->empty());
143 EXPECT_FALSE(H->empty());
144 EXPECT_FALSE(J->empty());
145 EXPECT_FALSE(verifyModule(*M, &dbgs()));
146 }
147
84148 TEST(BitReaderTest, MaterializeFunctionsForBlockAddr) { // PR11677
85149 SmallString<1024> Mem;
86150