This is an archive of the discontinued LLVM Phabricator instance.

[AIX] Check for typedef properly when getting preferred type align
ClosedPublic

Authored by stevewan on Sep 7 2021, 12:55 PM.

Details

Summary

The current check for typedef is naive and doesn't deal with any convoluted cases. This patch makes use of the new 'AlignRequirement' enum field from 'TypeInfo' to determine whether or not this is an 'aligned' attribute on a typedef.

Diff Detail

Event Timeline

stevewan requested review of this revision.Sep 7 2021, 12:55 PM
stevewan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2021, 12:55 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rjmccall accepted this revision.Sep 7 2021, 1:33 PM

LGTM, except it's missing tests.

This revision is now accepted and ready to land.Sep 7 2021, 1:33 PM

LGTM, except it's missing tests.

Thanks. This is an NFC patch, the tests added in https://reviews.llvm.org/D107598 should still suffice IMHO.

stevewan retitled this revision from [AIX] Check for typedef properly when getting preferred type align to [NFC][AIX] Check for typedef properly when getting preferred type align.Sep 7 2021, 1:49 PM

Oh, no, I don't think this is NFC. It seems very likely that there's some case where the behavior is distinguishable. Maybe a typedef of a record with an alignment attribute?

__attribute__((aligned(2), packed)) struct float4 { float x, y, z, w; };
typedef struct float4 float4typedef;

struct {
  float4typedef field; // presumably still eligible for alignment upgrade
};

Oh, no, I don't think this is NFC. It seems very likely that there's some case where the behavior is distinguishable. Maybe a typedef of a record with an alignment attribute?

__attribute__((aligned(2), packed)) struct float4 { float x, y, z, w; };
typedef struct float4 float4typedef;

struct {
  float4typedef field; // presumably still eligible for alignment upgrade
};

Right, the behaviour difference is exactly what I'm trying to fix, silly me :). Though the diff isn't very obvious in the given example because ABIAlign equals to PreferredAlign in that particular case, the following test may provide a better exposure,

struct __attribute__((aligned(2))) S { double x; };
typedef struct S SS;
stevewan retitled this revision from [NFC][AIX] Check for typedef properly when getting preferred type align to [AIX] Check for typedef properly when getting preferred type align.Sep 8 2021, 12:16 PM
stevewan updated this revision to Diff 371418.Sep 8 2021, 12:34 PM

Add test case

rjmccall accepted this revision.Sep 8 2021, 1:19 PM

Thanks, LGTM.

This revision was landed with ongoing or failed builds.Sep 8 2021, 1:22 PM
This revision was automatically updated to reflect the committed changes.