]> git.lizzy.rs Git - rust.git/commit
Fixes issue 39827: ICE in volatile_store intrinsic
authorAlexey Tarasov <tarasov@dodologics.com>
Sat, 12 Aug 2017 08:42:44 +0000 (18:42 +1000)
committerAlexey Tarasov <tarasov@dodologics.com>
Sat, 12 Aug 2017 08:42:44 +0000 (18:42 +1000)
commit0cd358742dfcf3fa6b0d8a318cfb5cc748dc905d
tree944cf6399d0b2ed24f9703afc71133b70b810659
parent2fa5340318111d562af2ef4897c75916731d55a2
Fixes issue 39827: ICE in volatile_store intrinsic

- adds handling of zero-sized types for volatile_store.
- adds type size checks and warnigns for other volatile intrinsics.
- adds a test to check warnings emitting.

Cause of the issue

While preparing for trans_intrinsic_call() invoke arguments are
processed with trans_argument() method which excludes zero-sized types
from argument list (to be more correct - all arguments for which
ArgKind is Ignore are filtered out). As result volatile_store() intrinsic
gets one argument instead of expected address and value.

How it is fixed

Modification of the trans_argument() method may cause side effects,
therefore change was implemented in volatile_store() intrinsic building
code itself. Now it checks function signature and if it was specialised
with zero-sized type, then emits C_nil() instead of accessing
non-existing second argument.

Additionally warnings are added for all volatile operations which are
specialised with zero-sized arguments. In fact, those operations are omitted
in LLVM backend if no memory affected at all, e.g. number of elements
is zero or type is zero-sized. This was not explicitly documented before
and could lead to potential issues if developer expects volatile behaviour,
but type has degraded to zero-sized.
src/librustc_trans/intrinsic.rs
src/test/ui/issue-39827.rs [new file with mode: 0644]
src/test/ui/issue-39827.stderr [new file with mode: 0644]