llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Eli Friedman (efriedma-quic)

<details>
<summary>Changes</summary>

Under the Microsoft ABI, a class with a user-provided constructor cannot be 
returned in a register.  This check was fixed in 3ab4ae9e58c09 to also handle 
template constructors.  That fix missed a special case of the special case: a 
deleted template constructor does not count as user-provided.

Fixes #<!-- -->237188

---
Full diff: https://github.com/llvm/llvm-project/pull/237634.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.md (+5) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+2-1) 
- (modified) clang/test/CodeGen/arm64-microsoft-arguments.cpp (+13) 


``````````diff
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 53d688d2e11e7c..a75ad9ca7fc74b 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -157,6 +157,11 @@ features cannot lower the translation-unit ABI level;
   accesses to these fields. `__attribute__((packed))` on the field or the
   enclosing record still reduces the alignment. (#GH208256)
 
+- On Windows targets using Microsoft C++ ABI, fixed returning a class with
+  a deleted template constructor which should be returned in a register.
+  This affects the ABI of `std::strong_ordering` in some versions of the
+  Microsoft STL. (#GH237188)
+
 ### AST Dumping Potentially Breaking Changes
 
 ### Clang Frontend Potentially Breaking Changes
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 86916104d13440..73c889d27c2a13 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1172,7 +1172,8 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, 
QualType Ty,
       if (Ctor->isUserProvided())
         return false;
     } else if (auto *Template = dyn_cast<FunctionTemplateDecl>(D)) {
-      if (isa<CXXConstructorDecl>(Template->getTemplatedDecl()))
+      if (isa<CXXConstructorDecl>(Template->getTemplatedDecl()) &&
+          !Template->getTemplatedDecl()->isDeleted())
         return false;
     } else if (auto *MethodDecl = dyn_cast<CXXMethodDecl>(D)) {
       if (MethodDecl->isCopyAssignmentOperator() && MethodDecl->isDeleted())
diff --git a/clang/test/CodeGen/arm64-microsoft-arguments.cpp 
b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
index 50a1b1f6bf5549..5a49eaf83c7cc3 100644
--- a/clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -216,3 +216,16 @@ S12 f12() {
   S12 x((int*)0);
   return func12(x);
 }
+
+// GH237188
+// Ignore deleted template constructor
+// CHECK: define dso_local i32 @"?f13@@YA?AUS13@@PEAU1@@Z"(ptr noundef {{.*}})
+// CHECK: call i32 @"?func13@@YA?AUS13@@U1@@Z"(i32 {{.*}})
+struct S13 {
+  template<typename T> S13(T*) = delete;
+  int x;
+};
+S13 func13(S13 x);
+S13 f13(S13 *p) {
+  return func13(*p);
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/237634
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to