[all-commits] [llvm/llvm-project] 9fc458: [BPF] Fix erroneous removal of non-jump-table glob...
yonghong-song via All-commits
all-commits at lists.llvm.org
Thu Jun 18 18:38:22 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9fc458a1d95b9c3edf288e4ec2cd9dcd1fe0d895
https://github.com/llvm/llvm-project/commit/9fc458a1d95b9c3edf288e4ec2cd9dcd1fe0d895
Author: yonghong-song <yhs at fb.com>
Date: 2026-06-18 (Thu, 18 Jun 2026)
Changed paths:
M llvm/lib/Target/BPF/BPFAsmPrinter.cpp
A llvm/test/CodeGen/BPF/jump_table_func_ptr_array.ll
Log Message:
-----------
[BPF] Fix erroneous removal of non-jump-table globals (#204594)
Jump tables are supported only for cpu v4. After lowering them into
.jumptables entries, BPFAsmPrinter::doFinalization() removes the private
constant arrays that backed the jump tables. But the below 'for' loop is
actually a no-op.
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
if (!dyn_cast<BlockAddress>(CA->getOperand(i)))
continue;
}
Targets.push_back(&Global);
With current implementation, 'Global' will be added to 'Targets' and
later in doFinalization(), 'Global' will be removed. But it is possible
in 'Global' there exists non BlockAddress which are used in later code.
This will cause the problem like:
error: Undefined temporary symbol .L__const.select_fn.fns
To fix the problem, For the above 'for' loop, only if all operands are
with BlockAddress, 'Global' can be pushed to 'Targets'.
The issue is discovered when running bpf selftest with -O1. The related
file is
tools/testing/selftests/bpf/progs/kprobe_multi_session.c
Before optimization, we have
@__const.session_check.kfuncs = private unnamed_addr constant [8 x ptr]
[ptr @bpf_fentry_test1, ptr @bpf_fentry_test2, ptr @bpf_fentry_test3,
ptr @bpf_fentry_test4, ptr @bpf_fentry_test5, ptr @bpf_fentry_test6,
ptr @bpf_fentry_test7, ptr @bpf_fentry_test8], align 8
With -O1, `@__const.session_check.kfuncs` is used in codegen like
...
$r2 = LD_imm64 @__const.session_check.kfuncs
...
which triggered the compilation failure.
With -O2, `@__const.session_check.kfuncs` is inlined in llvm
GlobalOptPass and each individual funciton `@bpf_fentry_test1` etc. is
directly used in IR, e.g.,
...
%9 = icmp eq i64 %8, ptrtoint (ptr @bpf_fentry_test1 to i64), !dbg !95
...
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list