[cfe-commits] r62447 - /cfe/trunk/lib/Lex/PTHLexer.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Sun Jan 18 03:54:30 PST 2009


Chris Lattner wrote:
> Author: lattner
> Date: Sat Jan 17 20:19:16 2009
> New Revision: 62447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=62447&view=rev
> Log:
> On i386 and x86-64, just do unaligned loads 
> instead of assembling from bytes.  This speeds up -Eonly PTH reading 
> of cocoa.h by about 2ms, which is 4.2%.
>
> +#if defined(__i386__) || defined(__x86_64__)
>   

We need a central place for determining this support, and then define a
config macro based on this, so that the locations using this can just write

#if defined(CLANG_UNALIGNED_LOADSTORE)

or something like that. The current method is too brittle. Aside from
being complicated to extend to other platforms (you have to hunt down
every place that does this, which gets complicated if we have more than
one place that tests capability by querying the platform instead of a
capability flag), compilers simply don't agree on the names for the
platform flags. So, to make the above work on both GCC and MSVC, you
have to write something like (can't remember the MS macros exactly):

#if defined(__i386__) || defined(_M_X86) || defined(__x86_64__) ||
defined(_M_AMD64)

which gets ugly very quickly.

Sebastian



More information about the cfe-commits mailing list