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

Mark error constructors cold #166

Merged
merged 1 commit into from
Sep 12, 2021
Merged

Mark error constructors cold #166

merged 1 commit into from
Sep 12, 2021

Conversation

stepancheg
Copy link
Contributor

All #[cold] to all error constructors.

As discussed in the issue #165,
marking functions cold helps LLVM optimize code paths not leading to error.

Although in our case marking only from was enough, I took the
liberty of marking all error constructors #[cold].

Note, I marked cold both inner function and public functions, because
LLVM does not always takes into account #[cold] attribute of inlined functions,
see an example in compiled explorer.

All `#[cold]` to all error constructors.

As discussed in the [issue dtolnay#165](dtolnay#165),
marking functions cold helps LLVM optimize code paths not leading to error.

Although in our case marking only `from` was enough, I took the
liberty of marking all error constructors `#[cold]`.

Note, I marked cold both inner function and public functions, because
LLVM does not always takes into account `#[cold]` attribute of inlined functions,
see [an example in compiled explorer](https://rust.godbolt.org/z/vzxazMMnb).
Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 447eff8 into dtolnay:master Sep 12, 2021
@stepancheg stepancheg deleted the cold branch September 12, 2021 19:24
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.

2 participants