Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73f8adc
commit 4b70269
Showing
18 changed files
with
502 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2012 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. | ||
|
||
#[no_mangle] | ||
pub extern "C" fn foo() -> uint { | ||
1234 | ||
} |
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,17 @@ | ||
// Copyright 2012 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. | ||
|
||
#[inline] | ||
pub fn cci_fn() -> uint { | ||
1200 | ||
} | ||
|
||
#[inline] | ||
pub static CCI_STATIC: uint = 34; |
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,31 @@ | ||
// Copyright 2012 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. | ||
|
||
// compile-flags: -C codegen-units=3 --crate-type=rlib,dylib | ||
|
||
pub mod a { | ||
pub fn one() -> uint { | ||
1 | ||
} | ||
} | ||
|
||
pub mod b { | ||
pub fn two() -> uint { | ||
2 | ||
} | ||
} | ||
|
||
pub mod c { | ||
use a::one; | ||
use b::two; | ||
pub fn three() -> uint { | ||
one() + two() | ||
} | ||
} |
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,28 @@ | ||
// Copyright 2012 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. | ||
|
||
// Make sure we give a sane error message when the user requests LTO with a | ||
// library built with -C codegen-units > 1. | ||
|
||
// aux-build:sepcomp_lib.rs | ||
// compile-flags: -Z lto | ||
// error-pattern:missing compressed bytecode | ||
// no-prefer-dynamic | ||
|
||
extern crate sepcomp_lib; | ||
use sepcomp_lib::a::one; | ||
use sepcomp_lib::b::two; | ||
use sepcomp_lib::c::three; | ||
|
||
fn main() { | ||
assert_eq!(one(), 1); | ||
assert_eq!(two(), 2); | ||
assert_eq!(three(), 3); | ||
} |
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,10 @@ | ||
-include ../tools.mk | ||
|
||
# Check that cross-crate inlined items are inlined in all compilation units | ||
# that refer to them, and not in any other compilation units. | ||
|
||
all: | ||
$(RUSTC) cci_lib.rs | ||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3 | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*cci_fn)" -eq "2" ] | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c CCI_STATIC.*=.*constant)" -eq "2" ] |
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,19 @@ | ||
// Copyright 2012 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. | ||
|
||
#![crate_type = "rlib"] | ||
|
||
#[inline] | ||
pub fn cci_fn() -> uint { | ||
1234 | ||
} | ||
|
||
#[inline] | ||
pub static CCI_STATIC: uint = 2345; |
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,36 @@ | ||
// Copyright 2014 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. | ||
|
||
extern crate cci_lib; | ||
use cci_lib::{cci_fn, CCI_STATIC}; | ||
|
||
fn call1() -> uint { | ||
cci_fn() + CCI_STATIC | ||
} | ||
|
||
mod a { | ||
use cci_lib::cci_fn; | ||
pub fn call2() -> uint { | ||
cci_fn() | ||
} | ||
} | ||
|
||
mod b { | ||
use cci_lib::CCI_STATIC; | ||
pub fn call3() -> uint { | ||
CCI_STATIC | ||
} | ||
} | ||
|
||
fn main() { | ||
call1(); | ||
a::call2(); | ||
b::call3(); | ||
} |
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,13 @@ | ||
-include ../tools.mk | ||
|
||
# Test that #[inline(always)] functions still get inlined across compilation | ||
# unit boundaries. Compilation should produce three IR files, with each one | ||
# containing a definition of the inlined function. Also, the non-#[inline] | ||
# function should be defined in only one compilation unit. | ||
|
||
all: | ||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3 | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*inlined)" -eq "1" ] | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ available_externally\ i32\ .*inlined)" -eq "2" ] | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*normal)" -eq "1" ] | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c declare\ i32\ .*normal)" -eq "2" ] |
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,35 @@ | ||
// Copyright 2014 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. | ||
|
||
#[inline] | ||
fn inlined() -> u32 { | ||
1234 | ||
} | ||
|
||
fn normal() -> u32 { | ||
2345 | ||
} | ||
|
||
mod a { | ||
pub fn f() -> u32 { | ||
::inlined() + ::normal() | ||
} | ||
} | ||
|
||
mod b { | ||
pub fn f() -> u32 { | ||
::inlined() + ::normal() | ||
} | ||
} | ||
|
||
fn main() { | ||
a::f(); | ||
b::f(); | ||
} |
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,9 @@ | ||
-include ../tools.mk | ||
|
||
# Test that separate compilation actually puts code into separate compilation | ||
# units. `foo.rs` defines `magic_fn` in three different modules, which should | ||
# wind up in three different compilation units. | ||
|
||
all: | ||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3 | ||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*magic_fn)" -eq "3" ] |
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,27 @@ | ||
// Copyright 2014 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. | ||
|
||
fn magic_fn() -> uint { | ||
1234 | ||
} | ||
|
||
mod a { | ||
pub fn magic_fn() -> uint { | ||
2345 | ||
} | ||
} | ||
|
||
mod b { | ||
pub fn magic_fn() -> uint { | ||
3456 | ||
} | ||
} | ||
|
||
fn main() { } |
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,41 @@ | ||
// Copyright 2012 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. | ||
|
||
// compile-flags: -C codegen-units=3 | ||
// aux-build:sepcomp_cci_lib.rs | ||
|
||
// Test accessing cross-crate inlined items from multiple compilation units. | ||
|
||
extern crate sepcomp_cci_lib; | ||
use sepcomp_cci_lib::{cci_fn, CCI_STATIC}; | ||
|
||
fn call1() -> uint { | ||
cci_fn() + CCI_STATIC | ||
} | ||
|
||
mod a { | ||
use sepcomp_cci_lib::{cci_fn, CCI_STATIC}; | ||
pub fn call2() -> uint { | ||
cci_fn() + CCI_STATIC | ||
} | ||
} | ||
|
||
mod b { | ||
use sepcomp_cci_lib::{cci_fn, CCI_STATIC}; | ||
pub fn call3() -> uint { | ||
cci_fn() + CCI_STATIC | ||
} | ||
} | ||
|
||
fn main() { | ||
assert_eq!(call1(), 1234); | ||
assert_eq!(a::call2(), 1234); | ||
assert_eq!(b::call3(), 1234); | ||
} |
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 2012 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. | ||
|
||
// compile-flags: -C codegen-units=3 | ||
// aux-build:sepcomp-extern-lib.rs | ||
|
||
// Test accessing external items from multiple compilation units. | ||
|
||
#[link(name = "sepcomp-extern-lib")] | ||
extern { | ||
#[allow(ctypes)] | ||
fn foo() -> uint; | ||
} | ||
|
||
fn call1() -> uint { | ||
unsafe { foo() } | ||
} | ||
|
||
mod a { | ||
pub fn call2() -> uint { | ||
unsafe { ::foo() } | ||
} | ||
} | ||
|
||
mod b { | ||
pub fn call3() -> uint { | ||
unsafe { ::foo() } | ||
} | ||
} | ||
|
||
fn main() { | ||
assert_eq!(call1(), 1234); | ||
assert_eq!(a::call2(), 1234); | ||
assert_eq!(b::call3(), 1234); | ||
} |
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,41 @@ | ||
// Copyright 2012 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. | ||
|
||
// compile-flags: -C codegen-units=3 | ||
|
||
// Test references to items that haven't been translated yet. | ||
|
||
// Generate some code in the first compilation unit before declaring any | ||
// modules. This ensures that the first module doesn't go into the same | ||
// compilation unit as the top-level module. | ||
fn pad() -> uint { 0 } | ||
|
||
mod b { | ||
pub fn three() -> uint { | ||
::one() + ::a::two() | ||
} | ||
} | ||
|
||
mod a { | ||
pub fn two() -> uint { | ||
::one() + ::one() | ||
} | ||
} | ||
|
||
fn one() -> uint { | ||
1 | ||
} | ||
|
||
fn main() { | ||
assert_eq!(one(), 1); | ||
assert_eq!(a::two(), 2); | ||
assert_eq!(b::three(), 3); | ||
} | ||
|
Oops, something went wrong.