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
Disassembler
MCTargetDesc BPF: Add more relocation kinds 2021-05-25 08:19:13 -07:00
TargetInfo
BPF.h
BPF.td
BPFAbstractMemberAccess.cpp [BPF] Use elementtype attribute for preserve.array/struct.index intrinsics 2021-07-17 11:09:18 +02:00
BPFAdjustOpt.cpp
BPFAsmPrinter.cpp
BPFCallingConv.td
BPFCheckAndAdjustIR.cpp
BPFCORE.h
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFInstrFormats.td
BPFInstrInfo.cpp
BPFInstrInfo.h
BPFInstrInfo.td
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
BPFMIPeephole.cpp
BPFMISimplifyPatchable.cpp
BPFPreserveDIType.cpp
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp
BPFSelectionDAGInfo.h
BPFSubtarget.cpp
BPFSubtarget.h
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
BTF.h
BTFDebug.cpp
BTFDebug.h
CMakeLists.txt