llvm.org GIT mirror llvm / f6572d0
Generalize LCSSA to handle loops with exits with predecessors outside the loop. This is needed because with indirectbr it may not be possible for LoopSimplify to guarantee that all loop exit predecessors are inside the loop. This fixes PR5437. LCCSA no longer actually requires LoopSimplify form, but for now it must still have the dependency because the PassManager doesn't know how to schedule LoopSimplify otherwise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86569 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
2 changed file(s) with 649 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6262 ///
6363 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
6464 AU.setPreservesCFG();
65
66 // LCSSA doesn't actually require LoopSimplify, but the PassManager
67 // doesn't know how to schedule LoopSimplify by itself.
6568 AU.addRequiredID(LoopSimplifyID);
6669 AU.addPreservedID(LoopSimplifyID);
6770 AU.addRequiredTransitive();
213216 SSAUpdate.Initialize(Inst);
214217
215218 // Insert the LCSSA phi's into all of the exit blocks dominated by the
216 // value., and add them to the Phi's map.
219 // value, and add them to the Phi's map.
217220 for (SmallVectorImpl::const_iterator BBI = ExitBlocks.begin(),
218221 BBE = ExitBlocks.end(); BBI != BBE; ++BBI) {
219222 BasicBlock *ExitBB = *BBI;
227230 PN->reserveOperandSpace(PredCache.GetNumPreds(ExitBB));
228231
229232 // Add inputs from inside the loop for this PHI.
230 for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI)
233 for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) {
231234 PN->addIncoming(Inst, *PI);
235
236 // If the exit block has a predecessor not within the loop, arrange for
237 // the incomging value use corresponding to that predecessor to be
238 // rewritten in terms of a different LCSSA PHI.
239 if (!inLoop(*PI))
240 UsesToRewrite.push_back(
241 &PN->getOperandUse(
242 PN->getOperandNumForIncomingValue(PN->getNumIncomingValues()-1)));
243 }
232244
233245 // Remember that this phi makes the value alive in this block.
234246 SSAUpdate.AddAvailableValue(ExitBB, PN);
0 ; RUN: opt < %s -lcssa -verify-loop-info -verify-dom-info -disable-output
1 ; PR5437
2
3 ; LCSSA should work correctly in the case of an indirectbr that exits
4 ; the loop, and the loop has exits with predecessors not within the loop
5 ; (and btw these edges are unsplittable due to the indirectbr).
6
7 define i32 @js_Interpret() nounwind {
8 entry:
9 br i1 undef, label %"4", label %"3"
10
11 "3": ; preds = %entry
12 ret i32 0
13
14 "4": ; preds = %entry
15 br i1 undef, label %"6", label %"5"
16
17 "5": ; preds = %"4"
18 unreachable
19
20 "6": ; preds = %"4"
21 br i1 undef, label %"10", label %"13"
22
23 "10": ; preds = %"6"
24 br i1 undef, label %"22", label %"15"
25
26 "13": ; preds = %"6"
27 unreachable
28
29 "15": ; preds = %"23", %"10"
30 unreachable
31
32 "22": ; preds = %"10"
33 br label %"23"
34
35 "23": ; preds = %"1375", %"22"
36 %0 = phi i32 [ undef, %"22" ], [ %1, %"1375" ] ; [#uses=1]
37 indirectbr i8* undef, [label %"15", label %"24", label %"25", label %"26", label %"27", label %"28", label %"29", label %"30", label %"32", label %"32", label %"33", label %"35", label %"36", label %"41", label %"41", label %"60", label %"61", label %"65", label %"76", label %"87", label %"95", label %"103", label %"104", label %"108", label %"119", label %"130", label %"138", label %"146", label %"164", label %"162", label %"163", label %"166", label %"167", label %"173", label %"173", label %"173", label %"173", label %"173", label %"192", label %"193", label %"194", label %"196", label %"206", label %"231", label %"241", label %"251", label %"261", label %"307", label %"353", label %"354", label %"355", label %"361", label %"367", label %"400", label %"433", label %"466", label %"499", label %"509", label %"519", label %"529", label %"571", label %"589", label %"607", label %"635", label %"655", label %"664", label %"671", label %"680", label %"687", label %"692", label %"698", label %"704", label %"715", label %"715", label %"716", label %"725", label %"725", label %"725", label %"725", label %"724", label %"724", label %"724", label %"724", label %"737", label %"737", label %"737", label %"737", label %"761", label %"758", label %"759", label %"760", label %"766", label %"763", label %"764", label %"765", label %"771", label %"768", label %"769", label %"770", label %"780", label %"777", label %"778", label %"779", label %"821", label %"826", label %"831", label %"832", label %"833", label %"836", label %"836", label %"886", label %"905", label %"978", label %"978", label %"1136", label %"1166", label %"1179", label %"1201", label %"1212", label %"1212", label %"1274", label %"1284", label %"1284", label %"1346", label %"1347", label %"1348", label %"1349", label %"1350", label %"1353", label %"1353", label %"1353", label %"1355", label %"1355", label %"1357", label %"1357", label %"1358", label %"1359", label %"1374", label %"1375", label %"1376", label %"1377", label %"1378", label %"1379", label %"1386", label %"1395", label %"1394", label %"1425", label %"1426", label %"1440", label %"1449", label %"1455", label %"1461", label %"1471", label %"1482", label %"1484", label %"1486", label %"1489", label %"1489", label %"1492", label %"1494", label %"1494", label %"1497", label %"1499", label %"1499", label %"1515", label %"1546", label %"1546", label %"1566", label %"1584", label %"1587", label %"1591", label %"1605", label %"1609", label %"1609", label %"1640", label %"1648", label %"1651", label %"1703", label %"1710", label %"1718", label %"1724", label %"1725", label %"1726", label %"1727", label %"1728", label %"1731", label %"1732", label %"1733", label %"1734", label %"1735", label %"1741", label %"1750", label %"1752", label %"1754", label %"1755", label %"1757", label %"1759", label %"1761", label %"1764", label %"1764", label %"1766", label %"1768", label %"1775", label %"1775", label %"1781", label %"1781", label %"1790", label %"1791", label %"1801", label %"1802", label %"1803", label %"1805", label %"1807", label %"1809", label %"1817", label %"1819", label %"1821", label %"1823", label %"1825", label %"1827", label %"1836", label %"1836", label %"1845", label %"1845", label %"1848", label %"1849", label %"1851", label %"1853", label %"1856", label %"1861", label %"1861"]
38
39 "24": ; preds = %"23"
40 unreachable
41
42 "25": ; preds = %"23"
43 unreachable
44
45 "26": ; preds = %"23"
46 unreachable
47
48 "27": ; preds = %"23"
49 unreachable
50
51 "28": ; preds = %"23"
52 unreachable
53
54 "29": ; preds = %"23"
55 unreachable
56
57 "30": ; preds = %"23"
58 unreachable
59
60 "32": ; preds = %"23", %"23"
61 unreachable
62
63 "33": ; preds = %"23"
64 unreachable
65
66 "35": ; preds = %"23"
67 unreachable
68
69 "36": ; preds = %"23"
70 unreachable
71
72 "60": ; preds = %"23"
73 unreachable
74
75 "61": ; preds = %"23"
76 unreachable
77
78 "65": ; preds = %"23"
79 unreachable
80
81 "76": ; preds = %"23"
82 unreachable
83
84 "87": ; preds = %"23"
85 unreachable
86
87 "95": ; preds = %"23"
88 unreachable
89
90 "103": ; preds = %"23"
91 unreachable
92
93 "104": ; preds = %"23"
94 unreachable
95
96 "108": ; preds = %"23"
97 unreachable
98
99 "119": ; preds = %"23"
100 unreachable
101
102 "130": ; preds = %"23"
103 unreachable
104
105 "138": ; preds = %"23"
106 unreachable
107
108 "146": ; preds = %"23"
109 unreachable
110
111 "162": ; preds = %"23"
112 unreachable
113
114 "163": ; preds = %"23"
115 unreachable
116
117 "164": ; preds = %"23"
118 unreachable
119
120 "166": ; preds = %"23"
121 unreachable
122
123 "167": ; preds = %"23"
124 unreachable
125
126 "173": ; preds = %"23", %"23", %"23", %"23", %"23"
127 unreachable
128
129 "192": ; preds = %"23"
130 unreachable
131
132 "193": ; preds = %"23"
133 unreachable
134
135 "194": ; preds = %"23"
136 unreachable
137
138 "196": ; preds = %"23"
139 unreachable
140
141 "206": ; preds = %"23"
142 unreachable
143
144 "231": ; preds = %"23"
145 unreachable
146
147 "241": ; preds = %"23"
148 unreachable
149
150 "251": ; preds = %"23"
151 unreachable
152
153 "261": ; preds = %"23"
154 unreachable
155
156 "307": ; preds = %"23"
157 unreachable
158
159 "353": ; preds = %"23"
160 unreachable
161
162 "354": ; preds = %"23"
163 unreachable
164
165 "355": ; preds = %"23"
166 unreachable
167
168 "361": ; preds = %"23"
169 unreachable
170
171 "367": ; preds = %"23"
172 unreachable
173
174 "400": ; preds = %"23"
175 unreachable
176
177 "433": ; preds = %"23"
178 unreachable
179
180 "466": ; preds = %"23"
181 unreachable
182
183 "499": ; preds = %"23"
184 unreachable
185
186 "509": ; preds = %"23"
187 unreachable
188
189 "519": ; preds = %"23"
190 unreachable
191
192 "529": ; preds = %"23"
193 unreachable
194
195 "571": ; preds = %"23"
196 unreachable
197
198 "589": ; preds = %"23"
199 unreachable
200
201 "607": ; preds = %"23"
202 unreachable
203
204 "635": ; preds = %"23"
205 unreachable
206
207 "655": ; preds = %"23"
208 unreachable
209
210 "664": ; preds = %"23"
211 unreachable
212
213 "671": ; preds = %"23"
214 unreachable
215
216 "680": ; preds = %"23"
217 unreachable
218
219 "687": ; preds = %"23"
220 unreachable
221
222 "692": ; preds = %"23"
223 br label %"1862"
224
225 "698": ; preds = %"23"
226 unreachable
227
228 "704": ; preds = %"23"
229 unreachable
230
231 "715": ; preds = %"23", %"23"
232 unreachable
233
234 "716": ; preds = %"23"
235 unreachable
236
237 "724": ; preds = %"23", %"23", %"23", %"23"
238 unreachable
239
240 "725": ; preds = %"23", %"23", %"23", %"23"
241 unreachable
242
243 "737": ; preds = %"23", %"23", %"23", %"23"
244 unreachable
245
246 "758": ; preds = %"23"
247 unreachable
248
249 "759": ; preds = %"23"
250 unreachable
251
252 "760": ; preds = %"23"
253 unreachable
254
255 "761": ; preds = %"23"
256 unreachable
257
258 "763": ; preds = %"23"
259 unreachable
260
261 "764": ; preds = %"23"
262 unreachable
263
264 "765": ; preds = %"23"
265 br label %"766"
266
267 "766": ; preds = %"765", %"23"
268 unreachable
269
270 "768": ; preds = %"23"
271 unreachable
272
273 "769": ; preds = %"23"
274 unreachable
275
276 "770": ; preds = %"23"
277 unreachable
278
279 "771": ; preds = %"23"
280 unreachable
281
282 "777": ; preds = %"23"
283 unreachable
284
285 "778": ; preds = %"23"
286 unreachable
287
288 "779": ; preds = %"23"
289 unreachable
290
291 "780": ; preds = %"23"
292 unreachable
293
294 "821": ; preds = %"23"
295 unreachable
296
297 "826": ; preds = %"23"
298 unreachable
299
300 "831": ; preds = %"23"
301 unreachable
302
303 "832": ; preds = %"23"
304 unreachable
305
306 "833": ; preds = %"23"
307 unreachable
308
309 "836": ; preds = %"23", %"23"
310 unreachable
311
312 "886": ; preds = %"23"
313 unreachable
314
315 "905": ; preds = %"23"
316 unreachable
317
318 "978": ; preds = %"23", %"23"
319 unreachable
320
321 "1136": ; preds = %"23"
322 unreachable
323
324 "1166": ; preds = %"23"
325 unreachable
326
327 "1179": ; preds = %"23"
328 unreachable
329
330 "1201": ; preds = %"23"
331 unreachable
332
333 "1212": ; preds = %"23", %"23"
334 unreachable
335
336 "1274": ; preds = %"23"
337 unreachable
338
339 "1284": ; preds = %"23", %"23"
340 unreachable
341
342 "1346": ; preds = %"23"
343 unreachable
344
345 "1347": ; preds = %"23"
346 unreachable
347
348 "1348": ; preds = %"23"
349 unreachable
350
351 "1349": ; preds = %"23"
352 unreachable
353
354 "1350": ; preds = %"23"
355 unreachable
356
357 "1353": ; preds = %"23", %"23", %"23"
358 unreachable
359
360 "1355": ; preds = %"23", %"23"
361 unreachable
362
363 "1357": ; preds = %"23", %"23"
364 unreachable
365
366 "1358": ; preds = %"23"
367 unreachable
368
369 "1359": ; preds = %"23"
370 unreachable
371
372 "1374": ; preds = %"23"
373 unreachable
374
375 "1375": ; preds = %"23"
376 %1 = zext i8 undef to i32 ; [#uses=1]
377 br label %"23"
378
379 "1376": ; preds = %"23"
380 unreachable
381
382 "1377": ; preds = %"23"
383 unreachable
384
385 "1378": ; preds = %"23"
386 unreachable
387
388 "1379": ; preds = %"23"
389 unreachable
390
391 "1386": ; preds = %"23"
392 unreachable
393
394 "1394": ; preds = %"23"
395 unreachable
396
397 "1395": ; preds = %"23"
398 unreachable
399
400 "1425": ; preds = %"23"
401 unreachable
402
403 "1426": ; preds = %"23"
404 unreachable
405
406 "1440": ; preds = %"23"
407 unreachable
408
409 "1449": ; preds = %"23"
410 unreachable
411
412 "1455": ; preds = %"23"
413 unreachable
414
415 "1461": ; preds = %"23"
416 unreachable
417
418 "1471": ; preds = %"23"
419 unreachable
420
421 "1482": ; preds = %"23"
422 unreachable
423
424 "1484": ; preds = %"23"
425 unreachable
426
427 "1486": ; preds = %"23"
428 unreachable
429
430 "1489": ; preds = %"23", %"23"
431 unreachable
432
433 "1492": ; preds = %"23"
434 unreachable
435
436 "1494": ; preds = %"23", %"23"
437 unreachable
438
439 "1497": ; preds = %"23"
440 unreachable
441
442 "1499": ; preds = %"23", %"23"
443 unreachable
444
445 "1515": ; preds = %"23"
446 unreachable
447
448 "1546": ; preds = %"23", %"23"
449 unreachable
450
451 "1566": ; preds = %"23"
452 br i1 undef, label %"1569", label %"1568"
453
454 "1568": ; preds = %"1566"
455 unreachable
456
457 "1569": ; preds = %"1566"
458 unreachable
459
460 "1584": ; preds = %"23"
461 unreachable
462
463 "1587": ; preds = %"23"
464 unreachable
465
466 "1591": ; preds = %"23"
467 unreachable
468
469 "1605": ; preds = %"23"
470 unreachable
471
472 "1609": ; preds = %"23", %"23"
473 unreachable
474
475 "1640": ; preds = %"23"
476 unreachable
477
478 "1648": ; preds = %"23"
479 unreachable
480
481 "1651": ; preds = %"23"
482 unreachable
483
484 "1703": ; preds = %"23"
485 unreachable
486
487 "1710": ; preds = %"23"
488 unreachable
489
490 "1718": ; preds = %"23"
491 unreachable
492
493 "1724": ; preds = %"23"
494 unreachable
495
496 "1725": ; preds = %"23"
497 unreachable
498
499 "1726": ; preds = %"23"
500 unreachable
501
502 "1727": ; preds = %"23"
503 unreachable
504
505 "1728": ; preds = %"23"
506 unreachable
507
508 "1731": ; preds = %"23"
509 unreachable
510
511 "1732": ; preds = %"23"
512 unreachable
513
514 "1733": ; preds = %"23"
515 unreachable
516
517 "1734": ; preds = %"23"
518 unreachable
519
520 "1735": ; preds = %"23"
521 unreachable
522
523 "1741": ; preds = %"23"
524 unreachable
525
526 "1750": ; preds = %"23"
527 unreachable
528
529 "1752": ; preds = %"23"
530 unreachable
531
532 "1754": ; preds = %"23"
533 unreachable
534
535 "1755": ; preds = %"23"
536 unreachable
537
538 "1757": ; preds = %"23"
539 unreachable
540
541 "1759": ; preds = %"23"
542 unreachable
543
544 "1761": ; preds = %"23"
545 unreachable
546
547 "1764": ; preds = %"23", %"23"
548 %2 = icmp eq i32 %0, 168 ; [#uses=0]
549 unreachable
550
551 "1766": ; preds = %"23"
552 unreachable
553
554 "1768": ; preds = %"23"
555 unreachable
556
557 "1775": ; preds = %"23", %"23"
558 unreachable
559
560 "1781": ; preds = %"23", %"23"
561 unreachable
562
563 "1790": ; preds = %"23"
564 unreachable
565
566 "1791": ; preds = %"23"
567 unreachable
568
569 "1801": ; preds = %"23"
570 unreachable
571
572 "1802": ; preds = %"23"
573 unreachable
574
575 "1803": ; preds = %"23"
576 unreachable
577
578 "1805": ; preds = %"23"
579 unreachable
580
581 "1807": ; preds = %"23"
582 unreachable
583
584 "1809": ; preds = %"23"
585 unreachable
586
587 "1817": ; preds = %"23"
588 unreachable
589
590 "1819": ; preds = %"23"
591 unreachable
592
593 "1821": ; preds = %"23"
594 unreachable
595
596 "1823": ; preds = %"23"
597 unreachable
598
599 "1825": ; preds = %"23"
600 unreachable
601
602 "1827": ; preds = %"23"
603 unreachable
604
605 "1836": ; preds = %"23", %"23"
606 br label %"1862"
607
608 "1845": ; preds = %"23", %"23"
609 unreachable
610
611 "1848": ; preds = %"23"
612 unreachable
613
614 "1849": ; preds = %"23"
615 unreachable
616
617 "1851": ; preds = %"23"
618 unreachable
619
620 "1853": ; preds = %"23"
621 unreachable
622
623 "1856": ; preds = %"23"
624 unreachable
625
626 "1861": ; preds = %"23", %"23"
627 unreachable
628
629 "41": ; preds = %"23", %"23"
630 unreachable
631
632 "1862": ; preds = %"1836", %"692"
633 unreachable
634 }