-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Closed
Closed
Copy link
Labels
hangCompiler hang (infinite loop)Compiler hang (infinite loop)invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:optimizations
Description
The following commit is the anticipated bpf jump table support.
yonghong-song@1890225
But with the above commit, I found BranchFolding has an infinite loop.
The following is the reproducer:
-
Check out the above commit and do a build.
-
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;
}
- The following clang compilation has a hang:
$ clang --target=bpf -O2 -S test2.c
^C
- 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 ...
Metadata
Metadata
Assignees
Labels
hangCompiler hang (infinite loop)Compiler hang (infinite loop)invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:optimizations