[cfe-dev] Unable to get Clang to obey target alignment requirements

Eli Friedman eli.friedman at gmail.com
Mon Dec 17 15:53:22 PST 2012


On Mon, Dec 17, 2012 at 5:10 AM, Stephen McGruer
<stephen.mcgruer at gmail.com> wrote:
> 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.)

-Eli



More information about the cfe-dev mailing list