Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an address_insignificant attribute #8421

Closed
wants to merge 1 commit into from

Conversation

alexcrichton
Copy link
Member

This can be applied to statics and it will indicate that LLVM will attempt to
merge the constant in .data with other statics.

I have preliminarily applied this to all of the statics generated by the new
ifmt! syntax extension. I compiled a file with 1000 calls to ifmt! and a
separate file with 1000 calls to fmt! to compare the sizes, and the results
were:

fmt           310k
ifmt (before) 529k
ifmt (after)  202k

This now means that ifmt! is both faster and smaller than fmt!, yay!

This can be applied to statics and it will indicate that LLVM will attempt to
merge the constant in .data with other statics.

I have preliminarily applied this to all of the statics generated by the new
`ifmt!` syntax extension. I compiled a file with 1000 calls to `ifmt!` and a
separate file with 1000 calls to `fmt!` to compare the sizes, and the results
were:

fmt           310k
ifmt (before) 529k
ifmt (after)  202k

This now means that ifmt! is both faster and smaller than fmt!, yay!
@sanxiyn
Copy link
Member

sanxiyn commented Aug 10, 2013

In the long term, shouldn't address_insignificant be the default, and address_significant marked by the attribute? Rust statics are constant...

@alexcrichton
Copy link
Member Author

I found out that llvm won't optimize this unless the constant also has an internal-type linkage. Thatmeans that statics marked pub won't benefit from this.

Additionally though, TLS keys all have significant addresses, and in my opinion it would be a real bummer to have to mark all of our tls keys with address_significant. An awesome solution to that possibly would be exportable macros from tls (and the macro throws on address_significant).

For now I think that normal statics shouldn't have this thrown on by default for the TLS reason, but other than that use case it's certainly worth a shot to see what starts crashing and burning.

bors added a commit that referenced this pull request Aug 11, 2013
This can be applied to statics and it will indicate that LLVM will attempt to
merge the constant in .data with other statics.

I have preliminarily applied this to all of the statics generated by the new
`ifmt!` syntax extension. I compiled a file with 1000 calls to `ifmt!` and a
separate file with 1000 calls to `fmt!` to compare the sizes, and the results
were:

```
fmt           310k
ifmt (before) 529k
ifmt (after)  202k
```

This now means that ifmt! is both faster and smaller than fmt!, yay!
@bors bors closed this Aug 11, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 24, 2022
Replace a few paths with diagnostic items

A fairly small change towards rust-lang#5393

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants