Issue |
149712
|
Summary |
[LLVM][BranchFolding] Infinite loop happens in BranchFolding with BPF jumptable support
|
Labels |
new issue
|
Assignees |
|
Reporter |
yonghong-song
|
The following commit is the anticipated bpf jump table support.
https://github.com/yonghong-song/llvm-project/commit/18902253d63e6ec0c0a3650e8bab8b714a22be9d
But with the above commit, I found BranchFolding has an infinite loop.
The following is the reproducer:
1. Check out the above commit and do a build.
2. Source code:
```
$ cat test2.c
int foo(int a, int b) {
__label__ l1, l2, l3, l4;
void *jt1[] = {[0]=&&l1, [1]=&&l2};
void *jt2[] = {[0]=&&l3, [1]=&&l4};
int ret = 0;
goto *jt1[a % 2];
l1: ret += 1;
l2: ret += 3;
goto *jt2[b % 2];
l3: ret += 5;
l4: ret += 7;
return ret;
}
```
3. The following clang compilation has a hang:
```
$ clang --target=bpf -O2 -S test2.c
^C
```
4. Then I added '-mllvm -debug-_only_=branch-folder'
```
$ clang --target=bpf -O2 -S test2.c -mllvm -debug-_only_=branch-folder >& log
^C
$ cat log
TryTailMergeBlocks: %bb.0, %bb.2
with successor %bb.1
which has fall-through from %bb.0
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.0 is 1
TryTailMergeBlocks: %bb.0, %bb.1
with successor %bb.2
which has fall-through from %bb.1
Looking for common tails of at least 3 instructions
Common tail length of %bb.1 and %bb.0 is 1
TryTailMergeBlocks: %bb.0, %bb.1, %bb.2
with successor %bb.3
which has fall-through from %bb.2
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.1 is 3
Common tail length of %bb.2 and %bb.0 is 1
Common tail length of %bb.1 and %bb.0 is 1
Using common tail in %bb.2 for %bb.1
Common tail length of %bb.2 and %bb.0 is 1
TryTailMergeBlocks: %bb.0, %bb.2
with successor %bb.4
which has fall-through from %bb.3
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.0 is 1
TryTailMergeBlocks: %bb.4, %bb.3
with successor %bb.5
which has fall-through from %bb.4
Looking for common tails of at least 3 instructions
TryTailMergeBlocks: %bb.0, %bb.2
with successor %bb.1
which has fall-through from %bb.0
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.0 is 1
TryTailMergeBlocks: %bb.0, %bb.1
with successor %bb.2
which has fall-through from %bb.1
Looking for common tails of at least 3 instructions
TryTailMergeBlocks: %bb.0, %bb.2
with successor %bb.4
which has fall-through from %bb.2
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.0 is 1
TryTailMergeBlocks: %bb.4, %bb.3
with successor %bb.5
which has fall-through from %bb.4
Looking for common tails of at least 3 instructions
TryTailMergeBlocks: %bb.0, %bb.2
with successor %bb.3
which has fall-through from %bb.5
Looking for common tails of at least 3 instructions
Common tail length of %bb.2 and %bb.0 is 1
...
```
There are infinite TryTailMergeBlocks ...
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs