[Scummvm-devel] Wii & Gamecube (resp. PowerPC) vs. unaligned memory access

Max Horn max at quendi.de
Mon May 9 14:16:02 CEST 2011


Am 09.05.2011 um 12:41 schrieb yotam barnoy:

>> Regarding 1: We rely on casts that violate aliasing rules in *tons* of places. So besides all else, we may want to recommend to all porters to add -fno-strict-aliasing, or even automatically add that to CXXFLAGS (when using GCC or any other compiler supporting this).
>> Any reason not to do so?
> 
> Though we violate aliasing rules in many places, I've only ever
> experienced an aliasing bug with the endian.h file. That was one of
> the worst bugs I ever had to debug btw.

Indeed, that is exactly the kind of nasty bugs I am afraid of; hence my desire to make the current READ_UINT* versions for GCC 4.x the default for GCC 4.x, *even* if supposedly we don't need to worry about unaligned access...

[For the record, that bug was discussed in this thread: <http://thread.gmane.org/gmane.games.devel.scummvm/8063>, and I should have searched for that earlier, because it contains quite some info on the reasoning behind our GCC 4.x READ_UINT* code. Thanks for reminding me about that, Yotam]


> It's possible of course that
> there may be other bugs waiting to be found, but I think that even
> though gcc says it must have strict aliasing, in reality the gcc guys
> realize that they can't just go and break a ton of code, all of which
> violates strict aliasing. So 95% of the time there's no issue.
> 
> The reason not to remove -fno-strict-aliasing is performance.

I assume you meant "not to add -fno-strict-aliasing" resp. "not to remove -fstrict-aliasing" and will reply to the following accordingly :)

> At least, last time we talked about aliasing, I suggested using
> -fno-strict-aliasing, and everyone replied that it would cause serious
> slowdown.

Hm, I can't seem to find that in the email archive nor do I recall it (the latter means nothing, just that my memory is as leaky as usual *sigh*). Can you point me to where that was discussed? Would be interesting to know and record (this time in a comment in endian.h, maybe) on which systems specifically there were noticeable or even "serious" slowdowns.


Cheers,
Max



More information about the Scummvm-devel mailing list