[PATCH] D156497: [BPF] Emit UNDEF rather than constant 0

Eduard Zingerman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 03:36:20 PDT 2023


eddyz87 added inline comments.


================
Comment at: llvm/test/Bindings/llvm-c/struct_ret2.ll:7
+; Before this test was introduced, the BPF backend would generate incorrect-but-viable code
+; that would pass the verifier and violate user expectations at runtime.
+;
----------------
yonghong-song wrote:
> The same here. I guess I must miss something. Do you mean bpf backend generates incorrect code, or it detects incorrect condition but proceed and eventually report a success rather than a failure?
> I must miss something here. 
Hi @yonghong-song ,

BPF backend detects and reports unsupported patterns, the report is done using function `diagnose()`. For diagnostic events with error severity `diagnose()` calls `exit(1)` if no other diagnostic handlers are installed ([[ https://reviews.llvm.org/D156497#4557395 | see comment ]]). However, the backend is also designed to proceed after issuing error diagnostics by injecting incorrect instructions. @tamird suggests to change some of these instructions to make it more obvious for BPF verifier that bytecode is bogus. The argument is that this would help during development of standalone tools that embed LLVM and for some reason install error handlers that don't react properly to error level diagnostics. I wonder what is the default error handler for embedders, let me check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156497/new/

https://reviews.llvm.org/D156497



More information about the llvm-commits mailing list