From 875e3bab86e9d22e7cc8995d7baf6d45c7474c9b Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Mon, 20 Nov 2023 00:40:51 -0500 Subject: [PATCH] Add warning to `check_allocs(...)` This function is useful for investigation and optimization, but we don't have sufficient parity/stability guarantees from the Julia compiler to use it for allocation-free guarantees at runtime. This adds a note to clarify that such a usage is _unsound_. --- src/AllocCheck.jl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AllocCheck.jl b/src/AllocCheck.jl index 87a019c..2a24c7e 100644 --- a/src/AllocCheck.jl +++ b/src/AllocCheck.jl @@ -170,7 +170,18 @@ end check_allocs(func, types; ignore_throw=true) Compiles the given function and types to LLVM IR and checks for allocations. -Returns a vector of `AllocationSite` structs, each containing a `CallInst` and a backtrace. + +Returns a vector of `AllocationSite`, `DynamicDispatch`, and `AllocatingRuntimeCall` + +!!! warning + The Julia language/compiler does not guarantee that this result is stable across + Julia invocations. + + If you rely on allocation-free code for safety/correctness, it is not sufficient + to verify `check_allocs` in test code and expect that the corresponding call in + production will not allocate at runtime. + + For this case, you must use `@check_allocs` instead. # Example ```jldoctest