Skip to content

Conversation

therealprof
Copy link
Contributor

Reduces build size by quite a bit in dev builds but to my surprise also
helps in optimised builds using set_bit/clear_bit indirectly via HAL
impls.

Closes #334

Signed-off-by: Daniel Egger [email protected]

Reduces build size by quite a bit in dev builds but to my surprise also
helps in optimised builds using set_bit/clear_bit indirectly via HAL
impls.

Closes #334

Signed-off-by: Daniel Egger <[email protected]>
@therealprof therealprof requested a review from a team as a code owner July 25, 2019 11:04
@rust-highfive
Copy link

r? @ryankurte

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Jul 25, 2019
@therealprof
Copy link
Contributor Author

e.g:

Bloat for example i2c_hal_ina260serial
Compiling ...
Analyzing target/thumbv6m-none-eabi/release/examples/i2c_hal_ina260serial

File  .text   Size          Crate Name
0.6%  72.9% 1.6KiB      [Unknown] main
0.1%   7.5%   168B stm32f042_hal? <stm32f042_hal::i2c::I2c<stm32f042::I2C1,PINS> as embedded_hal::blocking::i2c::WriteRead>::write_read
0.0%   5.8%   130B      [Unknown] __aeabi_uidiv
0.0%   3.4%    76B      [Unknown] __clzsi2
0.0%   2.9%    64B         ina260 ina260::INA260<I2C>::voltage
0.0%   2.9%    64B    cortex_m_rt Reset
0.0%   1.6%    36B  stm32f042_hal stm32f042_hal::i2c::I2c<stm32f042::I2C1,PINS>::send_byte
0.0%   1.4%    32B stm32f042_hal? <stm32f042_hal::serial::Tx<USART> as core::fmt::Write>::write_str
0.0%   0.3%     6B            std core::result::unwrap_failed
0.0%   0.3%     6B            std core::slice::slice_index_order_fail
0.0%   0.3%     6B            std core::panicking::panic_fmt
0.0%   0.3%     6B            std core::panicking::panic_bounds_check
0.0%   0.3%     6B            std core::slice::slice_index_len_fail
0.0%   0.1%     2B    cortex_m_rt HardFault_
0.0%   0.1%     2B    cortex_m_rt DefaultPreInit
0.0%   0.1%     2B    cortex_m_rt DefaultHandler_
0.0%   0.1%     2B     panic_halt rust_begin_unwind
0.0%   0.0%     0B                And 0 smaller methods. Use -n N to show more.
0.8% 100.0% 2.2KiB                .text section size, the file size is 258.6KiB

vs

Bloat for example i2c_hal_ina260serial
Compiling ...
Analyzing target/thumbv6m-none-eabi/release/examples/i2c_hal_ina260serial

File  .text   Size          Crate Name
0.6%  74.3% 1.6KiB      [Unknown] main
0.1%   7.3%   160B stm32f042_hal? <stm32f042_hal::i2c::I2c<stm32f042::I2C1,PINS> as embedded_hal::blocking::i2c::WriteRead>::write_read
0.0%   5.9%   130B      [Unknown] __aeabi_uidiv
0.0%   3.5%    76B      [Unknown] __clzsi2
0.0%   2.9%    64B         ina260 ina260::INA260<I2C>::voltage
0.0%   2.9%    64B    cortex_m_rt Reset
0.0%   1.5%    32B stm32f042_hal? <stm32f042_hal::serial::Tx<USART> as core::fmt::Write>::write_str
0.0%   0.3%     6B            std core::result::unwrap_failed
0.0%   0.3%     6B            std core::slice::slice_index_order_fail
0.0%   0.3%     6B            std core::panicking::panic_fmt
0.0%   0.3%     6B            std core::panicking::panic_bounds_check
0.0%   0.3%     6B            std core::slice::slice_index_len_fail
0.0%   0.1%     2B    cortex_m_rt HardFault_
0.0%   0.1%     2B    cortex_m_rt DefaultPreInit
0.0%   0.1%     2B    cortex_m_rt DefaultHandler_
0.0%   0.1%     2B     panic_halt rust_begin_unwind
0.0%   0.0%     0B                And 0 smaller methods. Use -n N to show more.
0.8% 100.0% 2.1KiB                .text section size, the file size is 257.4KiB

@therealprof
Copy link
Contributor Author

CC @adamgreig

Copy link
Member

@Disasm Disasm left a comment

Choose a reason for hiding this comment

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

LGTM!

@Disasm
Copy link
Member

Disasm commented Jul 25, 2019

bors r+

bors bot added a commit that referenced this pull request Jul 25, 2019
335: Also always inline set_bit/clear bit r=Disasm a=therealprof

Reduces build size by quite a bit in dev builds but to my surprise also
helps in optimised builds using set_bit/clear_bit indirectly via HAL
impls.

Closes #334

Signed-off-by: Daniel Egger <[email protected]>

Co-authored-by: Daniel Egger <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jul 25, 2019

Build succeeded

@bors bors bot merged commit 1202ec4 into master Jul 25, 2019
@bors bors bot deleted the more-always-inline branch July 25, 2019 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set_bit/clear_bit not inlined
4 participants