[llvm] [BPF] Add exception handling support with .bpf_cleanup section (PR #192164)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 11:17:57 PDT 2026


================
@@ -0,0 +1,121 @@
+; RUN: llc -mtriple=bpfel -mcpu=v4 -filetype=asm -o - %s | FileCheck --check-prefix=ASM %s
+; RUN: llc -mtriple=bpfel -mcpu=v4 -filetype=obj -o %t %s
+; RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s
+; RUN: llvm-readelf -r %t | FileCheck --check-prefix=RELOCS %s
+
+; Verify that invoke/landingpad with cleanup produces a .bpf_cleanup section
+; containing (call_site, landing_pad) pairs with R_BPF_64_NODYLD32 relocations.
+; Models a Rust BTreeMap insertion that may fail, with Drop cleanup
+; calling bpf_free to release allocated nodes.
+
+declare ptr @bpf_alloc(i64, i64)
+declare void @bpf_free(ptr)
+declare void @btree_insert(ptr, ptr, i64)
+declare i32 @rust_personality(i32, i64, ptr, ptr)
----------------
eddyz87 wrote:

do we want an example with `catch_unwind` call for completeness?

https://github.com/llvm/llvm-project/pull/192164


More information about the llvm-commits mailing list