.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:
Andreas Rumpf 2020-09-28 13:51:39 +02:00 • committed by GitHub
commit 50b6f6996a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 53 additions and 12 deletions

View file

@ -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
============