Commit 65fd9f1
authored
[Attributor] Support nested conditional branches (#168532)
The attributor can infer the alignment of %p at the call-site in this
example [1]:
```
define void @f(ptr align 8 %p, i1 %c1, i1 %c2) {
entry:
br i1 %c1, label %bb.1, label %exit
bb.1:
call void (...) @llvm.fake.use(ptr %p)
br label %exit
exit:
ret void
}
```
but not when there's an additional conditional branch:
```
define void @f(ptr align 8 %p, i1 %c1, i1 %c2) {
entry:
br i1 %c1, label %bb.1, label %exit
bb.1:
br i1 %c2, label %bb.2, label %exit
bb.2:
call void (...) @llvm.fake.use(ptr %p)
br label %exit
exit:
ret void
}
```
unless `-attributor-annotate-decl-cs` is enabled. This patch extends
`followUsesInMBEC` to handle such recursive branches.
n.b. admittedly I wrote this patch before discovering inferring the
alignment in this example is already possible with
`-attributor-annotate-decl-cs`, I came to realise this once writing the
tests, but this seems like a gap regardless looking at existing FIXMEs,
plus the alignment can now be inferred in this particular example
without the flag.
[1] https://godbolt.org/z/aKoc75so51 parent e4cff3c commit 65fd9f1
File tree
6 files changed
+234
-229
lines changed- llvm
- lib/Transforms/IPO
- test/Transforms
- Attributor
- FunctionAttrs
6 files changed
+234
-229
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| 668 | + | |
668 | 669 | | |
| 670 | + | |
| 671 | + | |
669 | 672 | | |
670 | 673 | | |
671 | 674 | | |
| |||
684 | 687 | | |
685 | 688 | | |
686 | 689 | | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | 690 | | |
707 | 691 | | |
708 | | - | |
| 692 | + | |
| 693 | + | |
709 | 694 | | |
710 | 695 | | |
711 | 696 | | |
| |||
714 | 699 | | |
715 | 700 | | |
716 | 701 | | |
717 | | - | |
718 | 702 | | |
719 | | - | |
| 703 | + | |
| 704 | + | |
720 | 705 | | |
721 | 706 | | |
722 | 707 | | |
723 | 708 | | |
724 | 709 | | |
725 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
726 | 714 | | |
727 | 715 | | |
728 | 716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
559 | | - | |
560 | 558 | | |
561 | 559 | | |
562 | 560 | | |
563 | | - | |
| 561 | + | |
564 | 562 | | |
565 | 563 | | |
566 | 564 | | |
| |||
630 | 628 | | |
631 | 629 | | |
632 | 630 | | |
633 | | - | |
634 | 631 | | |
635 | 632 | | |
636 | 633 | | |
637 | | - | |
| 634 | + | |
638 | 635 | | |
639 | 636 | | |
640 | 637 | | |
| |||
654 | 651 | | |
655 | 652 | | |
656 | 653 | | |
657 | | - | |
| 654 | + | |
658 | 655 | | |
659 | 656 | | |
660 | 657 | | |
| |||
0 commit comments