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

Inline {min,max}_value even in debug builds #64941

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Oct 1, 2019

I think it is worth to inline {min,max}_value even in debug builds.
See this godbolt link: https://godbolt.org/z/-COkVS

@Centril
Copy link
Contributor

Centril commented Oct 1, 2019

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Oct 1, 2019

⌛ Trying commit 3b49ab6 with merge 61430923b8b2f3e7565c7aa30a3eb96474641bd6...

@bors
Copy link
Contributor

bors commented Oct 1, 2019

☀️ Try build successful - checks-azure
Build commit: 61430923b8b2f3e7565c7aa30a3eb96474641bd6 (61430923b8b2f3e7565c7aa30a3eb96474641bd6)

@rust-timer
Copy link
Collaborator

Queued 61430923b8b2f3e7565c7aa30a3eb96474641bd6 with parent 22bc9e1, future comparison URL.

@jonas-schievink
Copy link
Contributor

Isn't perf only measuring compiler performance (which is always built in release mode)?

@tesuji
Copy link
Contributor Author

tesuji commented Oct 1, 2019

So how can I measure debug build of compiler?

I saw this code generated from debug build (godbolt link: https://godbolt.org/z/9cpH6U)

core::num::<impl u32>::max_value:
        mov     eax, 4294967295
        ret

example::bar:
        push    rax
        call    core::num::<impl u32>::max_value
        mov     dword ptr [rsp + 4], eax
        mov     eax, dword ptr [rsp + 4]
        pop     rcx
        ret

That code is generated from:

pub fn bar() -> u32 {
    u32::max_value()
}

So I think max_value should always be inlined?

@tesuji tesuji changed the title Experimental: Inline {min,max}_value even in debug builds Inline {min,max}_value even in debug builds Oct 2, 2019
@tesuji
Copy link
Contributor Author

tesuji commented Oct 2, 2019

r? @nnethercote (randomly assign)

@nnethercote
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 3, 2019

📌 Commit 3b49ab6 has been approved by nnethercote

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 3, 2019
@bors
Copy link
Contributor

bors commented Oct 3, 2019

⌛ Testing commit 3b49ab6 with merge aa84c93d98bab674e7b7953cc30dd70f6d4cd0c1...

Centril added a commit to Centril/rust that referenced this pull request Oct 3, 2019
…hercote

Inline `{min,max}_value` even in debug builds

I think it is worth to inline `{min,max}_value` even in debug builds.
See this godbolt link: https://godbolt.org/z/-COkVS
@Centril
Copy link
Contributor

Centril commented Oct 3, 2019

@bors retry rolled up.

bors added a commit that referenced this pull request Oct 3, 2019
Rollup of 2 pull requests

Successful merges:

 - #64941 (Inline `{min,max}_value` even in debug builds)
 - #65002 (Update llvm-project submodule)

Failed merges:

r? @ghost
@bors bors merged commit 3b49ab6 into rust-lang:master Oct 3, 2019
@bors
Copy link
Contributor

bors commented Oct 3, 2019

☔ The latest upstream changes (presumably #65045) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 3, 2019
@tesuji tesuji deleted the inline-max_min_value branch October 3, 2019 10:18
@scottmcm
Copy link
Member

The godbolt example says to me to just stop using max_value(), not to add an attribute.

See also rust-lang/rfcs#2700

@tesuji
Copy link
Contributor Author

tesuji commented Oct 10, 2019

@scottmcm What do you think about that case in #64996 and #65016 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants