[Simh] clang (was Re: XCode and LTO)
Mark Pizzolato - Info Comm
Mark at infocomm.com
Fri Apr 27 15:52:51 EDT 2012
On Friday, April 27, 2012, at 10:44 AM, Sergey Oboguev wrote:
> Declaring "loopval" as volatile (and perhaps global, rather than on-stack, to
> reduce chances of compiler disregarding volatile declaration) might do the
> trick.
The goal really isn't to cause a memory reference, but really to avoid the inlining on this specific function. We're trying to do enough 'spinning' to slow things down predictably here.
My inclination is to:
#if defined(_MSC_VER)
#define NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define NOINLINE __attribute__((noinline))
#else
#define NOINLINE
#endif
int32 NOINLINE rom_swapb(int32 val)
- Mark
> ----- Original Message ----
> From: Craig A. Berry <craigberry at mac.com>
> Subject: [Simh] clang (was Re: XCode and LTO)
>
>
> The comments in the code say, "To avoid smart compilers, the loopval
> variable is referenced in the function arguments so that the function
> expression is not loop invariant," which led me to the lucky guess that the
> compiler was inlining the function and then optimizing away the inlined code.
> So I made the following
> (non-portable) change:
>
> [...]
>
> If anyone knows of a more portable way to prevent inlining of rom_swapb(),
> it seems like it would be a good idea to do so.
More information about the Simh
mailing list