[PATCH] D112938: BPF: Workaround an InstCombine ICmp transformation with llvm.bpf.compare builtin
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 1 09:16:19 PDT 2021
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added a subscriber: hiraditya.
yonghong-song requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Commit acabad9ff6bf <https://reviews.llvm.org/rGacabad9ff6bf13e00305d9d8621ee8eafc1f8b08> ("[InstCombine] try to canonicalize icmp with
trunc op into mask and cmp") added a transformation to
convert "(conv)a < power_2_const" to "a & <const>" in certain
cases and bpf kernel verifier has to handle the resulted code
conservatively and this may reject otherwise legitimate program.
This commit tries to prevent such a transformation. A bpf backend
builtin llvm.bpf.compare is added. The ICMP insn, which is subject to
above InstCombine transformation, is converted to the builtin
function. The builtin function is later lowered to original ICMP insn,
certainly after InstCombine pass.
With this change, all affected bpf strobemeta* selftests are
passed now.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112938
Files:
llvm/include/llvm/IR/IntrinsicsBPF.td
llvm/lib/Target/BPF/BPFAdjustOpt.cpp
llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
llvm/test/CodeGen/BPF/adjust-opt-icmp3.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112938.383818.patch
Type: text/x-patch
Size: 8617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211101/4529e860/attachment.bin>
More information about the llvm-commits
mailing list