[cfe-dev] [RFC] Implement code generation for __unaligned

Roger Ferrer Ibanez via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 20 03:33:39 PST 2017


Hi all,

thanks for the feedback.

Richard: On a second thought, it looks like it may not have much impact in the code generation, at least in x86. This was just in case unaligned accesses start to appear in other targets. But maybe I’m being too cautious here. So I will drop the flag from the patch.

Reid: I agree that there is enough machinery now for packed fields and __unaligned would add little here. I will be dropping this from the patch as well.

Kind regards,
Roger


From: Reid Kleckner [mailto:rnk at google.com]
Sent: 17 February 2017 17:48
To: Roger Ferrer Ibanez
Cc: cfe-dev at lists.llvm.org; nd
Subject: Re: [cfe-dev] [RFC] Implement code generation for __unaligned

I don't think we want __unaligned to affect record layout, we just want it to affect the alignment used when loading and storing an unaligned type. That's the way I read the MSDN description of __unaligned. I don't think Clang should implement its own, different semantics from MSVC for __unaligned. That causes confusion and the compatibility issues you mention.

I think programmers already have enough tools to control record layout. They have __attribute__((packed)) and __attribute__((aligned(N))). What they don't have are good tools to take unaligned pointers from code they don't control and access them safely. The MSVC version of __unaligned lets you do that, so I think we should just finish implementing it as described and call it a day.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170220/b1e3f19c/attachment.html>


More information about the cfe-dev mailing list