1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/lib/Target/BPF
Yonghong Song f6a86e448a BPF: avoid NE/EQ loop exit condition
Kuniyuki Iwashima reported in [1] that llvm compiler may
convert a loop exit condition with "i < bound" to "i != bound", where
"i" is the loop index variable and "bound" is the upper bound.
In case that "bound" is not a constant, verifier will always have "i != bound"
true, which will cause verifier failure since to verifier this is
an infinite loop.

The fix is to avoid transforming "i < bound" to "i != bound".
In llvm, the transformation is done by IndVarSimplify pass.
The compiler checks loop condition cost (i = i + 1) and if the
cost is lower, it may transform "i < bound" to "i != bound".
This patch implemented getArithmeticInstrCost() in BPF TargetTransformInfo
class to return a higher cost for such an operation, which
will prevent the transformation for the test case
added in this patch.

 [1] https://lore.kernel.org/netdev/1994df05-8f01-371f-3c3b-d33d7836878c@fb.com/

Differential Revision: https://reviews.llvm.org/D107483

(cherry picked from commit e52946b9ababcbf8e6f40b1b15900ae2e795a1c6)
2021-08-06 12:45:53 -07: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: Add more relocation kinds 2021-05-25 08:19:13 -07: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] Use elementtype attribute for preserve.array/struct.index intrinsics 2021-07-17 11:09:18 +02:00
BPFAdjustOpt.cpp Update BPFAdjustOpt.cpp to accept select form of or as well 2021-02-20 18:29:58 +09:00
BPFAsmPrinter.cpp
BPFCallingConv.td
BPFCheckAndAdjustIR.cpp BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFCORE.h BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFFrameLowering.cpp
BPFFrameLowering.h
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
BPFISelDAGToDAG.cpp BPFISelDAGToDAG.cpp - don't dereference a dyn_cast<> result. NFCI. 2021-06-06 13:24:29 +01:00
BPFISelLowering.cpp [BPF] add support for 32 bit registers in inline asm 2021-05-16 11:01:47 -07:00
BPFISelLowering.h [BPF] add support for 32 bit registers in inline asm 2021-05-16 11:01:47 -07:00
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIChecking.cpp [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFMIPeephole.cpp BPF: Fix a bug in peephole TRUNC elimination optimization 2021-03-02 13:03:42 -08:00
BPFMISimplifyPatchable.cpp
BPFPreserveDIType.cpp BPF: permit type modifiers for __builtin_btf_type_id() relocation 2021-03-04 16:27:23 -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 [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose 2021-05-07 21:51:47 -07:00
BPFTargetMachine.h [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose 2021-05-07 21:51:47 -07:00
BPFTargetTransformInfo.h BPF: avoid NE/EQ loop exit condition 2021-08-06 12:45:53 -07:00
BTF.def [BPF] Add support for floats and doubles 2021-03-05 15:10:11 +01:00
BTF.h
BTFDebug.cpp BPF: generate BTF info for LD_imm64 loaded function pointer 2021-04-26 17:23:36 -07:00
BTFDebug.h BPF: generate BTF info for LD_imm64 loaded function pointer 2021-04-26 17:23:36 -07:00
CMakeLists.txt BPF: Add LLVMTransformUtils in CMakefile LINK_COMPONENTS 2021-02-25 15:43:25 -08:00