[PATCH] D155894: BPF: fail reports a fatal error

Tamir Duberstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 15:02:48 PDT 2023


tamird created this revision.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: All.
tamird requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently the BPF backend uses `fail` to emit unsupported error
diagnostics, which can be ignored by embedders (such as rustc).

In the specific case of too-many-arguments, the BPF backend currently
has this code when it finds an argument passed on the stack:

  fail(DL, DAG, "defined with too many args");
  InVals.push_back(DAG.getConstant(0, DL, VA.getLocVT()));

which produces miscompilation!

This patch promotes previously diagnostic errors to fatal errors as they
are indeed unrecoverable. It also improves the error message in the
specific case of stack-passed arguments to include the number of
arguments, and to print only once; it previously printed once for each
excess argument, producing:

  <unknown>:0:0: in function test_log i32 (ptr): too many args to t284: i64 = GlobalAddress<ptr @"_ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E"> 0
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args
  <unknown>:0:0: in function _ZN71_$LT$$u5b$u8$u3b$$u20$16$u5d$$u20$as$u20$aya_log_common..WriteToBuf$GT$5write17h9384e7bebb844e69E i64 (<16 x i8>, ptr, i64): defined with too many args

it will now print just one error with the number of excess arguments
indicated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155894

Files:
  llvm/lib/Target/BPF/BPFISelLowering.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155894.542695.patch
Type: text/x-patch
Size: 3683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230720/20ef3ee9/attachment-0001.bin>


More information about the llvm-commits mailing list