Skip to content

Commit 1654f08

Browse files
committed
Allow merging of statics generated by format!()
1 parent f15d6d2 commit 1654f08

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libsyntax/ext/format.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,19 @@ impl<'a, 'b> Context<'a, 'b> {
316316
/// These attributes are applied to all statics that this syntax extension
317317
/// will generate.
318318
fn static_attrs(&self) -> Vec<ast::Attribute> {
319+
// Flag statics as `inline` so LLVM can merge duplicate globals as much
320+
// as possible (which we're generating a whole lot of).
321+
let unnamed = self.ecx.meta_word(self.fmtsp, InternedString::new("inline"));
322+
let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
323+
319324
// Do not warn format string as dead code
320325
let dead_code = self.ecx.meta_word(self.fmtsp,
321326
InternedString::new("dead_code"));
322327
let allow_dead_code = self.ecx.meta_list(self.fmtsp,
323328
InternedString::new("allow"),
324329
vec!(dead_code));
325330
let allow_dead_code = self.ecx.attribute(self.fmtsp, allow_dead_code);
326-
return vec!(allow_dead_code);
331+
return vec!(unnamed, allow_dead_code);
327332
}
328333

329334
fn rtpath(&self, s: &str) -> Vec<ast::Ident> {

0 commit comments

Comments
 (0)