[clang] [RFC][clang][BPF] Make trivial uninit var value to be 0 (PR #125601)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 8 19:08:45 PST 2025
yonghong-song wrote:
I just updated a patch to change TrivialAutoVarInitMaxSize to 8 if TrivialAutoVarInit is set to Zero by clang bpf target. This should mostly solve the issue for xdp programs.
@eddyz87 suggested to improve middle-end compilation to issue proper warnings. This is what I initially wanted to do as well but feel it would be quite complicated esp. related to cross-functions. I am not sure how cross-file checking can be done for bpf programs since effectively, we do not do IR-level merge across files.
One thing I tried earlier is to do -fsanitize=undefined for bpf programs (see discourse discussion link in the description). There will be a 'undef' IR asm code to specify as undefined behavior at particular place. Current bpf backend maps 'undef' to a no-op.
What we could do is that bpf backend could map 'undef' to a BPF 'trap' insn. Later, if verifier hits a 'trap' insn, verification should fail. In case verifier won't be able to pass due to 'trap' insn even if the prog is legal, 'trap' insn can only be issued if -fsanitize=undefined is specified by user. WDYT?
https://github.com/llvm/llvm-project/pull/125601
More information about the cfe-commits
mailing list