1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +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
Disassembler [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
MCTargetDesc
TargetInfo
BPF.h
BPF.td
BPFAbstractMemberAccess.cpp
BPFAdjustOpt.cpp
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
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFInstrFormats.td
BPFInstrInfo.cpp [NFC] unsigned->Register in storeRegTo/loadRegFromStack 2020-02-03 14:22:16 +01:00
BPFInstrInfo.h [NFC] unsigned->Register in storeRegTo/loadRegFromStack 2020-02-03 14:22:16 +01:00
BPFInstrInfo.td
BPFISelDAGToDAG.cpp BPFISelDAGToDAG.cpp - don't dereference a dyn_cast<> result. NFCI. 2021-06-06 13:24:29 +01:00
BPFISelLowering.cpp
BPFISelLowering.h
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIChecking.cpp
BPFMIPeephole.cpp BPF: Fix a bug in peephole TRUNC elimination optimization 2021-03-02 13:03:42 -08:00
BPFMISimplifyPatchable.cpp [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPFPreserveDIType.cpp
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp [Alignment][NFC] Migrate SelectionDAGTargetInfo::EmitTargetCodeForMemcpy to Align 2020-06-30 13:12:31 +00:00
BPFSelectionDAGInfo.h
BPFSubtarget.cpp
BPFSubtarget.h
BPFTargetMachine.cpp
BPFTargetMachine.h
BPFTargetTransformInfo.h
BTF.def
BTF.h
BTFDebug.cpp
BTFDebug.h
CMakeLists.txt