auto merge of #9130 : alexcrichton/rust/inline-globals, r=thestinger
In #8185 cross-crate condition handlers were fixed by ensuring that globals didn't start appearing in different crates with different addressed. An unfortunate side effect of that pull request is that constants weren't inlined across crates (uint::bits is unknown to everything but libstd). This commit fixes this inlining by using the `available_eternally` linkage provided by LLVM. It partially reverts #8185, and then adds support for this linkage type. The main caveat is that not all statics could be inlined into other crates. Before this patch, all statics were considered "inlineable items", but an unfortunate side effect of how we deal with `&static` and `&[static]` means that these two cases cannot be inlined across crates. The translation of constants was modified to propogate this condition of whether a constant should be considered inlineable into other crates. Closes #9036
This commit is contained in:
commit
d1c05504ba
9 changed files with 157 additions and 59 deletions
|
|
@ -10,12 +10,21 @@
|
|||
|
||||
pub static global: int = 3;
|
||||
|
||||
static global0: int = 4;
|
||||
pub static global2: &'static int = &global0;
|
||||
|
||||
pub fn verify_same(a: &'static int) {
|
||||
let a = a as *int as uint;
|
||||
let b = &global as *int as uint;
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
|
||||
pub fn verify_same2(a: &'static int) {
|
||||
let a = a as *int as uint;
|
||||
let b = global2 as *int as uint;
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
|
||||
condition!{ pub test: int -> (); }
|
||||
|
||||
pub fn raise() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use other = xcrate_static_addresses;
|
|||
|
||||
pub fn main() {
|
||||
other::verify_same(&other::global);
|
||||
other::verify_same2(other::global2);
|
||||
|
||||
// Previously this fail'd because there were two addresses that were being
|
||||
// used when declaring constants.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue