Skip to content

Commit

Permalink
Add warning to check_allocs(...)
Browse files Browse the repository at this point in the history
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_.
  • Loading branch information
topolarity committed Nov 20, 2023
1 parent 20feb11 commit 875e3ba
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/AllocCheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 875e3ba

Please sign in to comment.