Using the LLVM backend of BPF, I sometimes get the wrong code to be generated.
For example, for the following program: int bpf_prog1(void *ign) { volatile unsigned long t = 0x8983984739ull; return *(unsigned long *)((0xffffffff8fff0002ull) + t); } The generated code is 0: 18 01 00 00 39 47 98 83 00 00 00 00 89 00 00 00 r1 = 590618314553ll 2: 7b 1a f8 ff 00 00 00 00 *(u64 *)(r10 - 8) = r1 3: 79 a1 f8 ff 00 00 00 00 r1 = *(u64 *)(r10 - 8) 4: 79 10 02 00 00 00 00 00 r0 = *(u64 *)(r1 + 2) 5: 95 00 00 00 00 00 00 00 exit The culprit seems to be in the offset check in BPFDAGToDAGISel::SelectAddr() ( and BPFDAGToDAGISel::SelectFIAddr() ). Currently, the check is done using: if (isInt<32>(CN->getSExtValue())) When in fact, the offset is 16-bit, so it should be done using: if (isInt<16>(CN->getSExtValue())) Please let me know what you think. Thanks, Nadav _______________________________________________ iovisor-dev mailing list iovisor-dev@lists.iovisor.org https://lists.iovisor.org/mailman/listinfo/iovisor-dev