Skip to content

Commit 79c346d

Browse files
committed
---
yaml --- r: 81646 b: refs/heads/master c: fd0fcba h: refs/heads/master v: v3
1 parent 7ec1ebf commit 79c346d

File tree

8 files changed

+72
-23
lines changed

8 files changed

+72
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7024a9d5298a6ead78cfead653b3697a40a1b8b7
2+
refs/heads/master: fd0fcba9f5b2ec9cb504d6f322c2dd89ab891e08
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/librustc/middle/trans/base.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,10 +2559,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
25592559
// LLVM type is not fully determined by the Rust type.
25602560
let (v, inlineable) = consts::const_expr(ccx, expr);
25612561
ccx.const_values.insert(id, v);
2562-
if !inlineable {
2563-
debug!("%s not inlined", sym);
2564-
ccx.non_inlineable_statics.insert(id);
2565-
}
2562+
let mut inlineable = inlineable;
25662563
exprt = true;
25672564

25682565
unsafe {
@@ -2578,8 +2575,30 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
25782575
lib::llvm::SetUnnamedAddr(g, true);
25792576
lib::llvm::SetLinkage(g,
25802577
lib::llvm::InternalLinkage);
2578+
2579+
// This is a curious case where we must make
2580+
// all of these statics inlineable. If a
2581+
// global is tagged as
2582+
// address_insignificant, then LLVM won't
2583+
// coalesce globals unless they have an
2584+
// internal linkage type. This means that
2585+
// external crates cannot use this global.
2586+
// This is a problem for things like inner
2587+
// statics in generic functions, because the
2588+
// function will be inlined into another
2589+
// crate and then attempt to link to the
2590+
// static in the original crate, only to
2591+
// find that it's not there. On the other
2592+
// side of inlininig, the crates knows to
2593+
// not declare this static as
2594+
// available_externally (because it isn't)
2595+
inlineable = true;
25812596
}
25822597

2598+
if !inlineable {
2599+
debug!("%s not inlined", sym);
2600+
ccx.non_inlineable_statics.insert(id);
2601+
}
25832602
ccx.item_symbols.insert(i.id, sym);
25842603
g
25852604
}

trunk/src/librustc/middle/trans/inline.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::vec;
2121
use syntax::ast;
2222
use syntax::ast_map::path_name;
2323
use syntax::ast_util::local_def;
24+
use syntax::attr;
2425

2526
pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId)
2627
-> ast::DefId {
@@ -68,7 +69,12 @@ pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId)
6869
match item.node {
6970
ast::item_static(*) => {
7071
let g = get_item_val(ccx, item.id);
71-
SetLinkage(g, AvailableExternallyLinkage);
72+
// see the comment in get_item_val() as to why this check is
73+
// performed here.
74+
if !attr::contains_name(item.attrs,
75+
"address_insignificant") {
76+
SetLinkage(g, AvailableExternallyLinkage);
77+
}
7278
}
7379
_ => {}
7480
}

trunk/src/librustpkg/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ fn no_rebuilding() {
939939
}
940940
941941
#[test]
942+
#[ignore]
942943
fn no_rebuilding_dep() {
943944
let p_id = PkgId::new("foo");
944945
let dep_id = PkgId::new("bar");

trunk/src/libstd/borrow.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn to_uint<T>(thing: &T) -> uint {
2222
/// Determine if two borrowed pointers point to the same thing.
2323
#[inline]
2424
pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
25-
(thing as *T) == (other as *T)
25+
to_uint(thing) == to_uint(other)
2626
}
2727

2828
// Equality for region pointers
@@ -70,17 +70,3 @@ impl<'self, T: TotalEq> TotalEq for &'self T {
7070
#[inline]
7171
fn equals(&self, other: & &'self T) -> bool { (**self).equals(*other) }
7272
}
73-
74-
#[cfg(test)]
75-
mod tests {
76-
use super::ref_eq;
77-
78-
#[test]
79-
fn test_ref_eq() {
80-
let x = 1;
81-
let y = 1;
82-
83-
assert!(ref_eq(&x, &x));
84-
assert!(!ref_eq(&x, &y));
85-
}
86-
}

trunk/src/libstd/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ pub mod raw {
11071107
Some(limit) => (true, limit),
11081108
None => (false, 0)
11091109
};
1110-
while(*(curr_ptr as *libc::c_char) != 0 as libc::c_char
1111-
&& ((limited_count && ctr < limit) || !limited_count)) {
1110+
while(((limited_count && ctr < limit) || !limited_count)
1111+
&& *(curr_ptr as *libc::c_char) != 0 as libc::c_char) {
11121112
let env_pair = from_c_str(
11131113
curr_ptr as *libc::c_char);
11141114
result.push(env_pair);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn foo<T>() -> int {
12+
#[address_insignificant]
13+
static a: int = 3;
14+
a
15+
}
16+
17+
pub fn bar() -> int {
18+
foo::<int>()
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast windows doesn't like aux-build
12+
// aux-build:xcrate_address_insignificant.rs
13+
14+
extern mod foo(name = "xcrate_address_insignificant");
15+
16+
fn main() {
17+
assert_eq!(foo::foo::<float>(), foo::bar());
18+
}

0 commit comments

Comments
 (0)