Unable to get Clang to obey target alignment requirements

I’m currently struggling with getting Clang and LLVM to use 4-byte alignment for my target backend (ARCompact). (My target uses 4-byte alignment for all targets whose size is >= 4.) With regards to Clang, I thought I had set the correct variables and the DescriptionString in Targets.cpp, but compiling a simple test case to LLVM IR shows that doubles are still aligned to 8-bytes!

A quick overview of the Targets.cpp code, the test file, and the outcome can be seen at http://pastebin.com/45y2N4dV

Does anyone know what I might be doing wrong?


You're probably getting bitten by ASTContext::getPreferredTypeAlign .
I'm sure we've discussed changing it to do some target-configurable
thing, but nobody ever sent a patch. (Patches welcome.)