about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-17 20:41:38 +0000
committerbors <bors@rust-lang.org>2014-06-17 20:41:38 +0000
commited3308098c7ddd00039f2fcb1a128791757b2b1b (patch)
tree155b49abd46e54baf74f488f3ab2f05d7f6f68c6 /src/libsyntax
parent2fd618e77accd37426819952ad443e50bb3c9015 (diff)
parentcad760b7703a961e5dbe7b02966c8dd5df742431 (diff)
downloadrust-ed3308098c7ddd00039f2fcb1a128791757b2b1b.tar.gz
rust-ed3308098c7ddd00039f2fcb1a128791757b2b1b.zip
auto merge of #14977 : pcwalton/rust/address-insignificant-reform, r=brson
`#[inline(never)]` is used.

Closes #8958.

This can break some code that relied on the addresses of statics
being distinct; add `#[inline(never)]` to the affected statics.

[breaking-change]

r? @brson
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_util.rs13
-rw-r--r--src/libsyntax/ext/format.rs10
2 files changed, 14 insertions, 9 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 372f69b805a..d28553da691 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -11,6 +11,8 @@
 use ast::*;
 use ast;
 use ast_util;
+use attr::{InlineNever, InlineNone};
+use attr;
 use codemap;
 use codemap::Span;
 use owned_slice::OwnedSlice;
@@ -742,6 +744,17 @@ pub fn get_inner_tys(ty: P<Ty>) -> Vec<P<Ty>> {
     }
 }
 
+/// Returns true if the static with the given mutability and attributes
+/// has a significant address and false otherwise.
+pub fn static_has_significant_address(mutbl: ast::Mutability,
+                                              attrs: &[ast::Attribute])
+                                              -> bool {
+    if mutbl == ast::MutMutable {
+        return true
+    }
+    let inline = attr::find_inline_attr(attrs);
+    inline == InlineNever || inline == InlineNone
+}
 
 #[cfg(test)]
 mod test {
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 33ea186db35..857eadfe57c 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -312,14 +312,6 @@ impl<'a, 'b> Context<'a, 'b> {
     /// These attributes are applied to all statics that this syntax extension
     /// will generate.
     fn static_attrs(&self) -> Vec<ast::Attribute> {
-        // Flag statics as `address_insignificant` so LLVM can merge duplicate
-        // globals as much as possible (which we're generating a whole lot of).
-        let unnamed = self.ecx
-                          .meta_word(self.fmtsp,
-                                     InternedString::new(
-                                         "address_insignificant"));
-        let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
-
         // Do not warn format string as dead code
         let dead_code = self.ecx.meta_word(self.fmtsp,
                                            InternedString::new("dead_code"));
@@ -327,7 +319,7 @@ impl<'a, 'b> Context<'a, 'b> {
                                                  InternedString::new("allow"),
                                                  vec!(dead_code));
         let allow_dead_code = self.ecx.attribute(self.fmtsp, allow_dead_code);
-        return vec!(unnamed, allow_dead_code);
+        return vec!(allow_dead_code);
     }
 
     fn rtpath(&self, s: &str) -> Vec<ast::Ident> {