optimize just parts of code

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
does anybody know if it is possible to tell gcc in the same source file to leave certain blocks unoptimized.

Florian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IMHO you cannot do that.

Why would you want it?

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd like to be able to have different optimization for different pieces/functions. IAR allows to do that, GCC as far as I know doesn't.
The option of creation different files doesn't always work because of encapsulation issues for example.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I´m writing a LIN 2.0 driver and I want to leave an interrupt routine, which is used to calibrate the internal rc - oscillator unoptimized, but optimize the rest for code size. The reason behind this is, that I don´t want that the user of the driver has to set the optimization level for the isr in his make file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fengels wrote:
I´m writing a LIN 2.0 driver and I want to leave an interrupt routine, which is used to calibrate the internal rc - oscillator unoptimized, but optimize the rest for code size.

Put the interrupt routine in a separate file and compile it by itself. You'll have to play with the makefile to set individual optimization levels for each file.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No chance. Better use inline asm or such for those things where you want to
make sure about the timing.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FYI, the GCC folks are aware that this is a desired feature (different levels of optimization within a single file). And I think that someone might be working on that, but it may take some time before it's implemented and released. This is just from browsing the gcc mailing list.