llvm.org GIT mirror llvm / aee63ad
InstrProfTest.cpp: Don't assume string literals are always merged. MSC18 Debug didn't merge them. FIXME: I tweaked just to appease a builder. Almost string literals should be addressed identically there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256459 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 3 years ago
1 changed file(s) with 37 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
225225 }
226226
227227 TEST_F(InstrProfTest, get_icall_data_merge1) {
228 InstrProfRecord Record11("caller", 0x1234, {1, 2});
229 InstrProfRecord Record12("caller", 0x1234, {1, 2});
230 InstrProfRecord Record2("callee1", 0x1235, {3, 4});
231 InstrProfRecord Record3("callee2", 0x1235, {3, 4});
232 InstrProfRecord Record4("callee3", 0x1235, {3, 4});
233 InstrProfRecord Record5("callee3", 0x1235, {3, 4});
234 InstrProfRecord Record6("callee4", 0x1235, {3, 5});
228 static const char caller[] = "caller";
229 static const char callee1[] = "callee1";
230 static const char callee2[] = "callee2";
231 static const char callee3[] = "callee3";
232 static const char callee4[] = "callee4";
233
234 InstrProfRecord Record11(caller, 0x1234, {1, 2});
235 InstrProfRecord Record12(caller, 0x1234, {1, 2});
236 InstrProfRecord Record2(callee1, 0x1235, {3, 4});
237 InstrProfRecord Record3(callee2, 0x1235, {3, 4});
238 InstrProfRecord Record4(callee3, 0x1235, {3, 4});
239 InstrProfRecord Record5(callee3, 0x1235, {3, 4});
240 InstrProfRecord Record6(callee4, 0x1235, {3, 5});
235241
236242 // 5 value sites.
237243 Record11.reserveSites(IPVK_IndirectCallTarget, 5);
238 InstrProfValueData VD0[] = {{(uint64_t) "callee1", 1},
239 {(uint64_t) "callee2", 2},
240 {(uint64_t) "callee3", 3},
241 {(uint64_t) "callee4", 4}};
244 InstrProfValueData VD0[] = {{uint64_t(callee1), 1},
245 {uint64_t(callee2), 2},
246 {uint64_t(callee3), 3},
247 {uint64_t(callee4), 4}};
242248 Record11.addValueData(IPVK_IndirectCallTarget, 0, VD0, 4, nullptr);
243249
244250 // No valeu profile data at the second site.
245251 Record11.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
246252
247 InstrProfValueData VD2[] = {{(uint64_t) "callee1", 1},
248 {(uint64_t) "callee2", 2},
249 {(uint64_t) "callee3", 3}};
253 InstrProfValueData VD2[] = {{uint64_t(callee1), 1},
254 {uint64_t(callee2), 2},
255 {uint64_t(callee3), 3}};
250256 Record11.addValueData(IPVK_IndirectCallTarget, 2, VD2, 3, nullptr);
251257
252 InstrProfValueData VD3[] = {{(uint64_t) "callee1", 1}};
258 InstrProfValueData VD3[] = {{uint64_t(callee1), 1}};
253259 Record11.addValueData(IPVK_IndirectCallTarget, 3, VD3, 1, nullptr);
254260
255 InstrProfValueData VD4[] = {{(uint64_t) "callee1", 1},
256 {(uint64_t) "callee2", 2},
257 {(uint64_t) "callee3", 3}};
261 InstrProfValueData VD4[] = {{uint64_t(callee1), 1},
262 {uint64_t(callee2), 2},
263 {uint64_t(callee3), 3}};
258264 Record11.addValueData(IPVK_IndirectCallTarget, 4, VD4, 3, nullptr);
259265
260266 // A differnt record for the same caller.
261267 Record12.reserveSites(IPVK_IndirectCallTarget, 5);
262 InstrProfValueData VD02[] = {{(uint64_t) "callee2", 5},
263 {(uint64_t) "callee3", 3}};
268 InstrProfValueData VD02[] = {{uint64_t(callee2), 5},
269 {uint64_t(callee3), 3}};
264270 Record12.addValueData(IPVK_IndirectCallTarget, 0, VD02, 2, nullptr);
265271
266272 // No valeu profile data at the second site.
267273 Record12.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);
268274
269 InstrProfValueData VD22[] = {{(uint64_t) "callee2", 1},
270 {(uint64_t) "callee3", 3},
271 {(uint64_t) "callee4", 4}};
275 InstrProfValueData VD22[] = {{uint64_t(callee2), 1},
276 {uint64_t(callee3), 3},
277 {uint64_t(callee4), 4}};
272278 Record12.addValueData(IPVK_IndirectCallTarget, 2, VD22, 3, nullptr);
273279
274280 Record12.addValueData(IPVK_IndirectCallTarget, 3, nullptr, 0, nullptr);
275281
276 InstrProfValueData VD42[] = {{(uint64_t) "callee1", 1},
277 {(uint64_t) "callee2", 2},
278 {(uint64_t) "callee3", 3}};
282 InstrProfValueData VD42[] = {{uint64_t(callee1), 1},
283 {uint64_t(callee2), 2},
284 {uint64_t(callee3), 3}};
279285 Record12.addValueData(IPVK_IndirectCallTarget, 4, VD42, 3, nullptr);
280286
281287 Writer.addRecord(std::move(Record11));
350356 }
351357
352358 TEST_F(InstrProfTest, get_icall_data_merge1_saturation) {
359 static const char bar[] = "bar";
360
353361 const uint64_t Max = std::numeric_limits::max();
354362
355363 InstrProfRecord Record1("foo", 0x1234, {1});
361369 auto Result2 = Writer.addRecord(std::move(Record2));
362370 ASSERT_EQ(Result2, instrprof_error::counter_overflow);
363371
364 InstrProfRecord Record3("bar", 0x9012, {8});
372 InstrProfRecord Record3(bar, 0x9012, {8});
365373 auto Result3 = Writer.addRecord(std::move(Record3));
366374 ASSERT_EQ(Result3, instrprof_error::success);
367375
368376 InstrProfRecord Record4("baz", 0x5678, {3, 4});
369377 Record4.reserveSites(IPVK_IndirectCallTarget, 1);
370 InstrProfValueData VD4[] = {{(uint64_t) "bar", 1}};
378 InstrProfValueData VD4[] = {{uint64_t(bar), 1}};
371379 Record4.addValueData(IPVK_IndirectCallTarget, 0, VD4, 1, nullptr);
372380 auto Result4 = Writer.addRecord(std::move(Record4));
373381 ASSERT_EQ(Result4, instrprof_error::success);
375383 // Verify value data counter overflow.
376384 InstrProfRecord Record5("baz", 0x5678, {5, 6});
377385 Record5.reserveSites(IPVK_IndirectCallTarget, 1);
378 InstrProfValueData VD5[] = {{(uint64_t) "bar", Max}};
386 InstrProfValueData VD5[] = {{uint64_t(bar), Max}};
379387 Record5.addValueData(IPVK_IndirectCallTarget, 0, VD5, 1, nullptr);
380388 auto Result5 = Writer.addRecord(std::move(Record5));
381389 ASSERT_EQ(Result5, instrprof_error::counter_overflow);