This is an archive of the discontinued LLVM Phabricator instance.

[AIX] "aligned" attribute should not decrease type alignment returned by __alignof__
ClosedPublic

Authored by stevewan on Aug 5 2021, 1:23 PM.

Details

Summary

__alignof__(x) always returns ABIAlign if the "x" is marked __attribute__((aligned())). However, the "aligned" attribute should only increase the alignment of a struct, or struct member, unless it's used together with the "packed" attribute, or used as a part of a typedef, in which case, the "aligned" attribute can both increase and decrease alignment.

Diff Detail

Event Timeline

stevewan requested review of this revision.Aug 5 2021, 1:23 PM
stevewan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2021, 1:23 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
stevewan edited the summary of this revision. (Show Details)Aug 5 2021, 1:25 PM

This is a split of the query portion from https://reviews.llvm.org/D107394.

sfertile accepted this revision.Aug 5 2021, 3:01 PM

LGTM, other then 1 small test update.

clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
22

Minor nit: add

namespace test3 {
struct __attribute__((__aligned__(16))) C {
    double x;
} c;

as a third test.

This revision is now accepted and ready to land.Aug 5 2021, 3:01 PM
stevewan updated this revision to Diff 364630.Aug 5 2021, 3:17 PM

Add third test case as suggested.

This revision was landed with ongoing or failed builds.Aug 5 2021, 3:19 PM
This revision was automatically updated to reflect the committed changes.