llvm-project/llvm/lib/Target/BPF
Yonghong Song 1959ead525 BPF: Implement TTI.getCmpSelInstrCost() properly
The Select insn in BPF is expensive as BPF backend
needs to resolve with conditionals.  This patch set
the getCmpSelInstrCost() to SCEVCheapExpansionBudget
for Select insn to prevent some Select insn related
optimizations.

This change is motivated during bcc code review for
   https://github.com/iovisor/bcc/pull/3270
where IndVarSimplifyPass eventually caused generating
the following asm code:
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      14:       16 05 40 00 00 00 00 00 if w5 == 0 goto +64 <LBB0_6>
      15:       bc 51 00 00 00 00 00 00 w1 = w5
      16:       04 01 00 00 ff ff ff ff w1 += -1
      17:       67 05 00 00 20 00 00 00 r5 <<= 32
      18:       77 05 00 00 20 00 00 00 r5 >>= 32
      19:       a6 01 01 00 05 00 00 00 if w1 < 5 goto +1 <LBB0_4>
      20:       b7 05 00 00 06 00 00 00 r5 = 6
  00000000000000a8 <LBB0_4>:
      21:       b7 02 00 00 00 00 00 00 r2 = 0
      22:       b7 01 00 00 00 00 00 00 r1 = 0
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      23:       7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1
      24:       7b 5a c0 ff 00 00 00 00 *(u64 *)(r10 - 64) = r5
Note that insn #15 has w1 = w5 and w1 is refined later but r5(w5) is
eventually saved on stack at insn #24 for later use. This cause
later verifier failures.

With this change, IndVarSimplifyPass won't do the above
transformation any more.

Differential Revision: https://reviews.llvm.org/D97479
2021-02-25 14:48:53 -08:00
..
AsmParser llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Disassembler [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
MCTargetDesc [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
TargetInfo llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
BPF.h [BPF][NewPM] Port bpf-adjust-opt to NPM and add it to pipeline 2020-11-26 10:11:26 -08:00
BPF.td
BPFAbstractMemberAccess.cpp BPF: avoid duplicated globals for CORE relocations 2020-10-06 22:37:49 -07:00
BPFAdjustOpt.cpp Update BPFAdjustOpt.cpp to accept select form of or as well 2021-02-20 18:29:58 +09:00
BPFAsmPrinter.cpp
BPFCORE.h BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFCallingConv.td
BPFCheckAndAdjustIR.cpp BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFISelDAGToDAG.cpp [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
BPFISelLowering.cpp
BPFISelLowering.h [TargetLowering][RISCV][AArch64][PowerPC] Enable BuildUDIV/BuildSDIV on illegal types before type legalization if we can find a larger legal type that supports MUL. 2021-02-11 09:43:13 -08:00
BPFInstrFormats.td [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFInstrInfo.cpp
BPFInstrInfo.h
BPFInstrInfo.td [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIChecking.cpp [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFMIPeephole.cpp
BPFMISimplifyPatchable.cpp
BPFPreserveDIType.cpp BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp
BPFSelectionDAGInfo.h
BPFSubtarget.cpp [X86][MC][Target] Initial backend support a tune CPU to support -mtune 2020-08-14 15:31:50 -07:00
BPFSubtarget.h [X86][MC][Target] Initial backend support a tune CPU to support -mtune 2020-08-14 15:31:50 -07:00
BPFTargetMachine.cpp BPF: Implement TTI.IntImmCost() properly 2021-02-11 08:35:25 -08:00
BPFTargetMachine.h BPF: Implement TTI.IntImmCost() properly 2021-02-11 08:35:25 -08:00
BPFTargetTransformInfo.h BPF: Implement TTI.getCmpSelInstrCost() properly 2021-02-25 14:48:53 -08:00
BTF.def
BTF.h
BTFDebug.cpp BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
BTFDebug.h BTFDebug.h - reduce MachineInstr.h include to forward declaration. NFCI. 2020-09-07 17:51:13 +01:00
CMakeLists.txt BPF: Add LLVMAnalysis in CMakefile LINK_COMPONENTS 2021-02-11 10:24:22 -08:00