This patch specifically tries to address an issue reported at
https://lore.kernel.org/bpf/20200812074826.GB754656@krava/
If one icmp condition is used in more than one places, prevent
this condition from inlining into multiple places.
For example,
cond = a < b ... select cond, val1, val2 ... br cond, block1, block2
In actually lowering, cond will be put into select_cc and br_cc
so we will have proper cond in the jmp inst.
It is reported this caused the issue if cond happens to be
pkt_ptr < pkt_end
due to particular kernel implementation.
The transformation here is to put a barrier after "cond = a < b"
so cond cannot be inlined into select/br. The pseudo generated code
looks like:
if a < b then tmp = 1 then tmp = 0 ... if (tmp == 1) val1; else val2 ... if (tmp == 1) goto block1; else goto block2;
The below llc flag is added to turn off this optimization if needed.
llc -march=bpf -bpf-disable-eval-cond-once t.ll
clang-format: please reformat the code