[clang] [clang] Handle trivial_abi attribute for Microsoft ABI. (PR #88857)

Tobias Hieta via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 18 23:36:02 PDT 2024


================
@@ -1105,6 +1105,11 @@ bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) const {
 
 static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
                              CodeGenModule &CGM) {
+  // If the record is marked with the trivial_abi attribute, we don't
+  // have to conform to the standard MSVC ABI.
+  if (RD->hasAttr<TrivialABIAttr>())
----------------
tru wrote:

So if I understand correctly:

- There are additional places in the microsoft code path where we don't handle trivial cases without the attribute.
- The glaring issue here with this PR is that if you put a trivial_abi struct in a struct it won't be marked as trivial itself since it doesn't search recursively.

Seems like there are many more places where we can do better, do we want to block this PR on the recursive search? What would the rules for that be? It can't just be that if you have a struct with a trivial_abi attribute inside any struct the parent should also be considered trivial. Would it be that isTrivialForMicrosoft would return true if the current struct passes the checks there and only contains a struct with a trivial_abi attribute?

https://github.com/llvm/llvm-project/pull/88857


More information about the cfe-commits mailing list