Commit ee3c91f
Yonghong Song
[BPF] Emit proper error message for insns with tied operands
Jonathan Cottrill reported a crash in [1] with the following command line:
$ echo 'r0 = atomic_fetch_add((u64*)(r2 + 0), r1)' | llvm-mc --arch bpf --filetype null
Note that in the above command, the insn specification requires that
r0 and r1 must be the same register. Otherwise, the crash will happen.
Let us add a case Match_InvalidTiedOperand to handle such invalid insns.
With this patch, the error message looks like below:
<stdin>:1:39: error: operand is not the same as the dst register
r0 = atomic_fetch_add((u64*)(r2 + 0), r1)
^
The error message is much better than the crash. Some other insns are also
covered by this patch.
$ echo 'w0 = xchg32_32(r2 + 0, w1)' | llvm-mc --arch bpf --filetype null
<stdin>:1:24: error: operand is not the same as the dst register
w0 = xchg32_32(r2 + 0, w1)
^
[1] #1451801 parent 0a822f8 commit ee3c91f
File tree
2 files changed
+15
-0
lines changed- llvm
- lib/Target/BPF/AsmParser
- test/MC/BPF
2 files changed
+15
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
351 | 354 | | |
352 | 355 | | |
353 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments