debugging PCH failures on powerpc-darwin8

Hi,
   I've been debugging the numerous failures in PCH tests seen in my powerpc-darwin8-g++-4.0.1 bootstrap of llvm/clang (release 3.0).

Full build/test log: http://www.csl.cornell.edu/~fang/sw/llvm/llvm-clang-release-3.0-powerpc-darwin8-g++-4.0.1-fink-build-log.txt

I've been running this failing test by hand:
bin/llvm-lit -v ../llvm-3.0.src/tools/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp

My debug trail is here:
http://paste.lisp.org/display/126363#4

It looks like the point of failure during reading of the PCH file shows that a decl ID number 184549376 is read, which happens to be 0x0b000000. Tracing through the write-out of the PCH finds that ID 11 is written out once, or 0x0000000b. Is it possible that the serialization/deserialization of these values got byte-swapped?

The machine I'm running on is a powerpc G4, big-endian.
CMakeCache.txt agrees:
IS_BIG_ENDIAN:INTERNAL=1

Where should I look next to debug/fix this?

Fang

  I've been debugging the numerous failures in PCH tests seen in my
powerpc-darwin8-g++-4.0.1 bootstrap of llvm/clang (release 3.0).

Full build/test log:
http://www.csl.cornell.edu/~fang/sw/llvm/llvm-clang-release-3.0-powerpc-darwin8-g++-4.0.1-fink-build-log.txt

I've been running this failing test by hand:
bin/llvm-lit -v
../llvm-3.0.src/tools/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp

My debug trail is here:
http://paste.lisp.org/display/126363#4

It looks like the point of failure during reading of the PCH file shows
that a decl ID number 184549376 is read, which happens to be 0x0b000000.
Tracing through the write-out of the PCH finds that ID 11 is written out
once, or 0x0000000b. Is it possible that the
serialization/deserialization of these values got byte-swapped?

The machine I'm running on is a powerpc G4, big-endian.
CMakeCache.txt agrees:
IS_BIG_ENDIAN:INTERNAL=1

I took a stab at byte-swapping in ASTDeclContextNameLookupTrait::ReadData() in ASTReader.cpp,
but any attempts to modify the location that contained 0x0b000000 resulted in a bus-error, so instead I added the byte-swap to
ASTDeclContextNameLookupTrait::EmitData() in ASTWriter.cpp, and not only did the expr.unary.noexcept/cg.cpp test PASS, but over 50 of the original 77 failing tests also PASSED!

I've attached the patch I applied. Can someone familiar with the AST/PCH serialization component examine why this patch works for me, and whether there's a "more correct" patch than what I've applied? Again, this patch fixes numerous PCH Decl ID out-of-range failures on powerpc-darwin8, bootstrapping with g++-4.0.1.

Improved test results after this patch:
http://paste.lisp.org/display/126363#9
(only 20 remaining failures)

Thanks,

Fang

clang-3.0-ASTWriter.patch (921 Bytes)