llvm-project/llvm/lib
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
..
Analysis Option to ignore llvm[.compiler].used uses in hasAddressTaken() 2021-02-25 10:06:24 -08:00
AsmParser Encode alignment attribute for `cmpxchg` 2021-02-11 15:17:50 -05:00
BinaryFormat [Debuginfo][DW_OP_implicit_pointer] (1/7) Support for DW_OP_LLVM_implicit_pointer 2021-01-15 14:45:04 +05:30
Bitcode Fix unstable SmallPtrSet iteration issues due to collectUsedGlobalVariables 2021-02-23 16:09:05 -08:00
Bitstream [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
CodeGen [DAG] Move simplification of SADDSAT/SSUBSAT/UADDSAT/USUBSAT of vXi1 to getNode() 2021-02-25 17:49:26 +00:00
DWARFLinker [dsymutil][DWARFLinker][NFC] make AddressManager not depending on the order of checks for relocations. 2021-01-31 16:34:10 +03:00
DebugInfo DebugInfo/Symbolize: Exclude ARM mapping symbols for .symtab symbolization after D95916 2021-02-12 11:04:20 -08:00
Demangle [Demangle] Support demangling Swift calling convention in MS demangler. 2021-01-27 13:24:54 -08:00
ExecutionEngine [JITLink] Fix comments about JITLink's generic link algorithm. 2021-02-24 21:02:37 +11:00
Extensions llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
FileCheck [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
Frontend [OpenMPIRBuilder] Implement collapseLoops. 2021-02-03 19:12:02 -06:00
FuzzMutate [FuzzMutate] Add mutator to modify instruction flags. 2021-01-23 19:05:20 +00:00
Fuzzer
IR [PM] Show the pass argument in pre/post-pass IR dumps 2021-02-25 14:02:00 -08:00
IRReader static const char *const foo => const char foo[] 2020-12-01 10:33:18 -08:00
InterfaceStub [elfabi] Fix a bug when .dynsym contains no non-local symbol 2021-02-19 11:36:53 -08:00
LTO [lto] Enable new PM when the PM config is non-empty 2021-02-15 20:49:09 +01:00
LineEditor llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Linker [llvm-link] fix IRMover returning wrong modified vector type 2021-02-22 11:29:42 +00:00
MC Support `#pragma clang section` directives on MachO targets 2021-02-25 09:30:10 -08:00
MCA [llvm] Use llvm::find (NFC) 2021-01-19 20:19:14 -08:00
Object collectUsedGlobalVariables: migrate SmallPtrSetImpl overload to SmallVecImpl overload after D97128 2021-02-23 16:09:06 -08:00
ObjectYAML [obj2yaml,yaml2obj] Add NumBlocks to the BBAddrMapEntry yaml field. 2021-02-22 18:08:26 -08:00
Option [clang][cli] NFC: Remove ArgList infrastructure for recording queries 2021-02-25 13:53:24 +01:00
Passes [ThinLTO][NewPM] Clean up dead code under -O0 2021-02-24 17:08:57 -08:00
ProfileData [llvm-profdata] Emit Error when Invalid MemOpSize Section is Created by llvm-profdata 2021-02-23 12:51:54 -08:00
Remarks [llvm] Use append_range (NFC) 2021-01-27 23:25:41 -08:00
Support [llvm] Check availability for os_signpost 2021-02-24 16:27:31 -08:00
TableGen Revert "[TableGen] Improve algorithms for processing template arguments" 2021-02-18 09:26:26 -05:00
Target BPF: Implement TTI.getCmpSelInstrCost() properly 2021-02-25 14:48:53 -08:00
Testing [clangd] Implement semanticTokens modifiers 2021-02-09 16:31:22 +01:00
TextAPI [llvm][TextAPI] add equality operator for InterfaceFile 2021-02-18 11:53:08 -08:00
ToolDrivers llvm-lib: Pull error printing code out of two functions 2021-01-26 19:13:30 -05:00
Transforms Add a nullptr check. 2021-02-25 12:01:11 -08:00
WindowsManifest llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
XRay [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
CMakeLists.txt llvmbuildectomy - support disabled native target 2020-11-13 15:50:13 +01:00