-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #43836 - taleks:issue-39827, r=arielb1
Fix for issue #39827 *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.
- Loading branch information
Showing
4 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
#![feature(core_intrinsics)] | ||
|
||
use std::intrinsics::{ volatile_copy_memory, volatile_store, volatile_load, | ||
volatile_copy_nonoverlapping_memory, | ||
volatile_set_memory }; | ||
|
||
// | ||
// This test ensures that volatile intrinsics can be specialised with | ||
// zero-sized types and, in case of copy/set functions, can accept | ||
// number of elements equal to zero. | ||
// | ||
fn main () { | ||
let mut dst_pair = (1, 2); | ||
let src_pair = (3, 4); | ||
let mut dst_empty = (); | ||
let src_empty = (); | ||
|
||
const COUNT_0: usize = 0; | ||
const COUNT_100: usize = 100; | ||
|
||
unsafe { | ||
volatile_copy_memory(&mut dst_pair, &dst_pair, COUNT_0); | ||
volatile_copy_nonoverlapping_memory(&mut dst_pair, &src_pair, 0); | ||
volatile_copy_memory(&mut dst_empty, &dst_empty, 100); | ||
volatile_copy_nonoverlapping_memory(&mut dst_empty, &src_empty, | ||
COUNT_100); | ||
volatile_set_memory(&mut dst_empty, 0, COUNT_100); | ||
volatile_set_memory(&mut dst_pair, 0, COUNT_0); | ||
volatile_store(&mut dst_empty, ()); | ||
volatile_store(&mut dst_empty, src_empty); | ||
volatile_load(&src_empty); | ||
} | ||
} |