You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BPF] Add jump table support with switch statements and computed goto
This patch adds jump table support. A new insn 'gotox <reg>' is
added to allow goto through a register. The register represents
the address in the current section.
Code:
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;
}
Compilation Command:
clang --target=bpf -O2 -S test2.c
But I observed that the above compilation command actually hangs
with BranchFolding. If I did the following:
bool BranchFolderLegacy::runOnMachineFunction(MachineFunction &MF) {
+ if (true) return false;
if (skipFunction(MF.getFunction()))
return false;
The compilation can be done successful. I roughly took a look
at the dbg trace, looks like there is an infinite loop in
BranchFolding. This patch is tested on top of commit:
commit 58c3aff (origin/main, origin/HEAD, main)
Author: Michał Górny <[email protected]>
Date: Sun Jul 20 05:26:51 2025 +0200
[libclc] Expose `prepare_builtins_*` variables in top-level CMakeLists (llvm#149657)
0 commit comments