diff options
author | Yonghong Song <yhs@fb.com> | 2018-09-20 22:24:27 +0000 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2018-09-20 22:24:27 +0000 |
commit | 150ca5143be586e81befc7ab689e1c058ab31710 (patch) | |
tree | c50ffdbc836adab4235b004535bc5272aa30d7aa /llvm/lib/CodeGen/MachineCopyPropagation.cpp | |
parent | bb993db080391241b390f8408ff12c16b1e29a84 (diff) | |
download | llvm-150ca5143be586e81befc7ab689e1c058ab31710.zip llvm-150ca5143be586e81befc7ab689e1c058ab31710.tar.gz llvm-150ca5143be586e81befc7ab689e1c058ab31710.tar.bz2 |
bpf: check illegal usage of XADD insn return value
Currently, BPF has XADD (locked add) insn support and the
asm looks like:
lock *(u32 *)(r1 + 0) += r2
lock *(u64 *)(r1 + 0) += r2
The instruction itself does not have a return value.
At the source code level, users often use
__sync_fetch_and_add()
which eventually translates to XADD. The return value of
__sync_fetch_and_add() is supposed to be the old value
in the xadd memory location. Since BPF::XADD insn does not
support such a return value, this patch added a PreEmit
phase to check such a usage. If such an illegal usage
pattern is detected, a fatal error will be reported like
line 4: Invalid usage of the XADD return value
if compiled with -g, or
Invalid usage of the XADD return value
if compiled without -g.
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 342692
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
0 files changed, 0 insertions, 0 deletions