bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order
authorYonghong Song <yhs@fb.com>
Wed, 25 Jul 2018 22:40:02 +0000 (22:40 +0000)
committerYonghong Song <yhs@fb.com>
Wed, 25 Jul 2018 22:40:02 +0000 (22:40 +0000)
commit71d81e5c8fcebb7663973d686ac1ad3309502f4b
treeb736fbd18247bcced3522642ad47914ce594235d
parent99ca3c0a617337902c2b2006231acc64397d9df3
bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order

Some BPF JIT backends would want to optimize memcpy in their own
architecture specific way.

However, at the moment, there is no way for JIT backends to see memcpy
semantics in a reliable way. This is due to LLVM BPF backend is expanding
memcpy into load/store sequences and could possibly schedule them apart from
each other further. So, BPF JIT backends inside kernel can't reliably
recognize memcpy semantics by peephole BPF sequence.

This patch introduce new intrinsic expand infrastructure to memcpy.

To get stable in-order load/store sequence from memcpy, we first lower
memcpy into BPF::MEMCPY node which then expanded into in-order load/store
sequences in expandPostRAPseudo pass which will happen after instruction
scheduling. By this way, kernel JIT backends could reliably recognize
memcpy through scanning BPF sequence.

This new memcpy expand infrastructure is gated by a new option:

  -bpf-expand-memcpy-in-order

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 337977
llvm/lib/Target/BPF/BPFISelLowering.cpp
llvm/lib/Target/BPF/BPFISelLowering.h
llvm/lib/Target/BPF/BPFInstrInfo.cpp
llvm/lib/Target/BPF/BPFInstrInfo.h
llvm/lib/Target/BPF/BPFInstrInfo.td
llvm/lib/Target/BPF/BPFSelectionDAGInfo.cpp [new file with mode: 0644]
llvm/lib/Target/BPF/BPFSelectionDAGInfo.h [new file with mode: 0644]
llvm/lib/Target/BPF/BPFSubtarget.h
llvm/lib/Target/BPF/CMakeLists.txt
llvm/test/CodeGen/BPF/memcpy-expand-in-order.ll [new file with mode: 0644]