In certain cases the BPF backend may be confronted with IR that cannot
be expressed as valid BPF assembly. Unfortunately not all LLVM APIs
permit errors to be propagated upwards; instead the backend is expected
to emit diagnostics which are interpreted by the embedding application
(i.e. clang). This means that the backend must sometimes produce
incorrect assembly to avoid tripping assertions upstream and rely on the
embedding application respecting its diagnostics rather than attempting
to use the incorrect assembly it has generated.
This patch changes the strategy taken by the BPF backend when it
encounters:
- definitions of functions which take more arguments than permitted by the BPF target.
- calls to functions which take more arguments than permitted by the BPF target.
Prior to this patch the BPF replaced overrunning arguments with
"constant 0"; after this patch it replaces them with UNDEF.
This change is an attempt at being defensive. While most embedders (e.g.
clang) correctly handle "error" diagnostics by aborting code generation,
users of the LLVM API may implement custom diagnostics handlers which do
not exit on "error". This is exacerbated by the lack of documentation
surrounding the diagnostics functions and severity levels.
By emitting UNDEF rather than "constant 0" this patch attempts to
prevent the resulting program from passing the BPF verifier. Prior to
this patch such programs would almost always pass the verifier but
behave incorrectly.
Reverses choices made in 20a8d8e (D20571) and 353a5e0 (D20726).
TargetLowering should not contain state, you don't need this