--- In AVR-Chat@yahoogroups.com, "bayramdavies" <Yahoo37849@...> wrote: > But, doesn't a C compiler [...] limit itself to the consideration > of a single translation unit at a time? That would mean that if > a called function is in a different unit there is no way of > knowing what global variables are touched. I suspect that that is usually the case. The gcc compiler has an option to compile all of the files at one go (used for whole program optimization). With that option, the compiler *could* examine functions defined in another file. I don't know if it does or not. >And, if the variable *isn't* modified by a function in a different >unit, why would it be "global" in the first place? A global variable needn't be modified by *every* function in the system. The optimization opportunity we're discussing only depends on whether or not a particular set of functions modifies a particular global variable. > I wonder if the inlining is done first, in which case the >optimization is unremarkable. Possibly. I didn't experiment with options to suppress the inlining. My goal was to show that in at least one case the compiler deduced that a global variable was loop invariant in spite of the presence of a call to another function in the loop. Don Kinzer ZBasic Microcontrollers http://www.zbasic.net
Message
Re: Volatile modifier
2012-04-17 by Don Kinzer
Attachments
- No local attachments were found for this message.