Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Base.donotdelete public #55774

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ New library functions
* `uuid7()` creates an RFC 9652 compliant UUID with version 7 ([#54834]).
* `insertdims(array; dims)` allows to insert singleton dimensions into an array which is the inverse operation to `dropdims`
* The new `Fix` type is a generalization of `Fix1/Fix2` for fixing a single argument ([#54653]).
* `Base.donotdelete` is now public. It prevents deadcode elemination of its arguments ([#55774]).

New library features
--------------------
Expand Down
8 changes: 4 additions & 4 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3705,11 +3705,11 @@ unused and delete the entire benchmark code).
the code is semantically equivalent to `donotdelete(2).`

!!! note
This intrinsic does not affect the semantics of code that is dead because it is
This function does not affect the semantics of code that is dead because it is
*unreachable*. For example, the body of the function `f(x) = false && donotdelete(x)`
may be deleted in its entirety. The semantics of this intrinsic only guarantee that
*if* the intrinsic is semantically executed, then there is some program state at
which the value of the arguments of this intrinsic were available (in a register,
may be deleted in its entirety. The semantics of this function only guarantee that
*if* the function is semantically executed, then there is some program state at
which the value of the arguments of this function were available (in a register,
in memory, etc.).

# Examples
Expand Down
4 changes: 3 additions & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Core: CodeInfo, SimpleVector, donotdelete, compilerbarrier, memoryrefnew, memoryrefget, memoryrefset!
using Core: CodeInfo, SimpleVector, compilerbarrier, memoryrefnew, memoryrefget, memoryrefset!

const Callable = Union{Function,Type}

Expand Down Expand Up @@ -1261,3 +1261,5 @@ typename(typeof(function < end)).constprop_heuristic = Core.SAMETYPE_HEURISTIC
typename(typeof(function > end)).constprop_heuristic = Core.SAMETYPE_HEURISTIC
typename(typeof(function << end)).constprop_heuristic = Core.SAMETYPE_HEURISTIC
typename(typeof(function >> end)).constprop_heuristic = Core.SAMETYPE_HEURISTIC

donotdelete(args...) = Core.donotdelete(args...)
3 changes: 2 additions & 1 deletion base/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ public
notnothing,
runtests,
text_colors,
depwarn
depwarn,
donotdelete