.noalias annotation; frontend support (#15419)
* .noalias annotation; frontend support * added .noalias support to Nim; implements https://github.com/nim-lang/RFCs/issues/204
This commit is contained in:
parent
453167a41e
commit
50b6f6996a
11 changed files with 53 additions and 12 deletions
|
|
@ -1764,6 +1764,21 @@ via ``.noSideEffect``. The rules 3 and 4 can also be approximated by a different
|
|||
can only passed to a parameter of a ``.noSideEffect`` proc.
|
||||
|
||||
|
||||
Noalias annotation
|
||||
==================
|
||||
|
||||
Since version 1.4 of the Nim compiler, there is a ``.noalias`` annotation for variables
|
||||
and parameters. It is mapped directly to C/C++'s ``restrict`` keyword and means that
|
||||
the underlying pointer is pointing to a unique location in memory, no other aliases to
|
||||
this location exist. It is *unchecked* that this alias restriction is followed, if the
|
||||
restriction is violated, the backend optimizer is free to miscompile the code.
|
||||
This is an **unsafe** language feature.
|
||||
|
||||
Ideally in later versions of the language, the restriction will be enforced at
|
||||
compile time. (Which is also why the name ``noalias`` was choosen instead of a more
|
||||
verbose name like ``unsafeAssumeNoAlias``.)
|
||||
|
||||
|
||||
Strict funcs
|
||||
============
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue