llvm/lib/Target/BPF
Yonghong Song 98a5765c03 bpf: signal error instead of silent drop for certain invalid asm insn
Currently, an invalid asm insn, either in an asm file or
in an inline asm format, might be silently dropped. This patch
fixed two places where this may happen by
signaling the error so user knows what goes wrong.

The following is an example to demonstrate error messages:

    -bash-4.2$ cat t.c
    int test(void *ctx) {
    #if defined(NO_ERROR)
      asm volatile("r0 = *(u16 *)skb[%0]" : : "i"(2));
    #elif defined(ERROR_1)
      asm volatile("r20 = *(u16 *)skb[%0]" : : "i"(2));
    #elif defined(ERROR_2)
      asm volatile("r0 = *(u16 *)(r1 + ?)" : :);
    #endif
      return 0;
    }
    -bash-4.2$ cat run.sh
    for macro in NO_ERROR ERROR_1 ERROR_2; do
      echo "===== compile for macro" $macro
      clang -D${macro} -O2 -target bpf -emit-llvm -S t.c
      echo "==llc=="
      llc -march=bpf -filetype=obj t.ll
    done
    -bash-4.2$ ./run.sh
    ===== compile for macro NO_ERROR
    ==llc==
    ===== compile for macro ERROR_1
    ==llc==
    <inline asm>:1:2: error: invalid register/token name
            r20 = *(u16 *)skb[2]
            ^
    note: !srcloc = 135
    ===== compile for macro ERROR_2
    ==llc==
    <inline asm>:1:21: error: unexpected token
            r0 = *(u16 *)(r1 + ?)
                               ^
    note: !srcloc = 210
    -bash-4.2$

Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329849 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 20:24:52 +00:00
..
AsmParser bpf: signal error instead of silent drop for certain invalid asm insn 2018-04-11 20:24:52 +00:00
Disassembler bpf: New decoder namespace for 32-bit subregister load/store 2018-02-23 23:49:31 +00:00
InstPrinter Remove some unused includes to fix layering. 2018-03-29 00:29:45 +00:00
MCTargetDesc bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections 2018-03-01 23:04:59 +00:00
TargetInfo Add backend name to Target to enable runtime info to be fed back into TableGen 2017-11-15 23:55:44 +00:00
BPF.h bpf: New post-RA peephole optimization pass to eliminate bad RA codegen 2018-03-13 06:47:06 +00:00
BPF.td bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections 2018-03-01 23:04:59 +00:00
BPFAsmPrinter.cpp bpf: add inline-asm support 2017-09-18 23:29:36 +00:00
BPFCallingConv.td bpf: New calling convention for 32-bit subregisters 2018-02-23 23:49:23 +00:00
BPFFrameLowering.cpp
BPFFrameLowering.h Move TargetFrameLowering.h to CodeGen where it's implemented 2017-11-03 22:32:11 +00:00
BPFInstrFormats.td bpf: add new insns for bswap_to_le and negation 2017-09-28 02:46:11 +00:00
BPFInstrInfo.cpp bpf: Support 32-bit subregister in various InstrInfo hooks 2018-02-23 23:49:29 +00:00
BPFInstrInfo.h Target/TargetInstrInfo.h -> CodeGen/TargetInstrInfo.h to match layering 2017-11-08 01:01:31 +00:00
BPFInstrInfo.td bpf: New instruction patterns for 32-bit subregister load and store 2018-02-23 23:49:28 +00:00
BPFISelDAGToDAG.cpp Fix a bunch of typoes. NFC 2018-03-30 22:22:31 +00:00
BPFISelLowering.cpp bpf: fix incorrect SELECT_CC lowering 2018-04-03 03:56:37 +00:00
BPFISelLowering.h bpf: Support i32 in getScalarShiftAmountTy method 2018-02-23 23:49:26 +00:00
BPFMCInstLower.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
BPFMCInstLower.h [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
BPFMIPeephole.cpp bpf: Enhance debug information for peephole optimization passes 2018-03-13 06:47:07 +00:00
BPFRegisterInfo.cpp bpf: Use markSuperRegs to mark reserved registers 2018-02-23 23:49:18 +00:00
BPFRegisterInfo.h [BPF] Return true in enableMultipleCopyHints(). 2018-02-18 10:09:54 +00:00
BPFRegisterInfo.td bpf: add 32bit register set 2017-09-22 04:36:35 +00:00
BPFSubtarget.cpp bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections 2018-03-01 23:04:59 +00:00
BPFSubtarget.h bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections 2018-03-01 23:04:59 +00:00
BPFTargetMachine.cpp bpf: New post-RA peephole optimization pass to eliminate bad RA codegen 2018-03-13 06:47:06 +00:00
BPFTargetMachine.h Revert "TargetMachine: Merge TargetMachine and LLVMTargetMachine" 2017-10-12 22:57:28 +00:00
CMakeLists.txt Sort targetgen calls in lib/Target/*/CMakeLists. 2018-04-04 12:37:44 +00:00
LLVMBuild.txt bpf: Add BPF AsmParser support in LLVM 2017-09-12 17:55:23 +00:00