[PATCH] D60748: Adds an option "malign-pass-aggregate" to make the alignment of the struct and union parameters compatible with the default gcc

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 19 15:22:30 PDT 2020


rnk added inline comments.


================
Comment at: clang/include/clang/Basic/LangOptions.def:353
 
+VALUE_LANGOPT(AlignPassingAggregate, 1, 0, "Compatible with gcc default passing struct and union (x86 only).")
+
----------------
If only codegen needs to know, a CodeGenOption would be better.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:1556
+
+      for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+           i != e; ++i) {
----------------
Any time you crack open a record to look at the fields, the code is probably wrong the first time you write it. :( In this case, I suspect you are not looking at base classes. Consider:
```
struct A {
  MyAlignedType Field;
};
struct B : A {};
void passbyval(B o);
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60748/new/

https://reviews.llvm.org/D60748





More information about the cfe-commits mailing list