]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ext/format.rs
auto merge of #15871 : dotdash/rust/unnamed_fmtstr, r=pcwalton
[rust.git] / src / libsyntax / ext / format.rs
index 2e86d1c005d1cb416fbfe78b44cdac833821c48c..b00924c15901612a509bf93d0f53e7e3d730f5da 100644 (file)
@@ -319,6 +319,11 @@ fn verify_same(&self,
     /// These attributes are applied to all statics that this syntax extension
     /// will generate.
     fn static_attrs(&self) -> Vec<ast::Attribute> {
+        // Flag statics as `inline` 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("inline"));
+        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"));
@@ -326,7 +331,7 @@ fn static_attrs(&self) -> Vec<ast::Attribute> {
                                                  InternedString::new("allow"),
                                                  vec!(dead_code));
         let allow_dead_code = self.ecx.attribute(self.fmtsp, allow_dead_code);
-        return vec!(allow_dead_code);
+        return vec!(unnamed, allow_dead_code);
     }
 
     fn rtpath(&self, s: &str) -> Vec<ast::Ident> {