]> granicus.if.org Git - clang/commitdiff
CodeGenObjCXX: handle inalloca appropriately for msgSend variant
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 28 Feb 2018 20:16:12 +0000 (20:16 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 28 Feb 2018 20:16:12 +0000 (20:16 +0000)
objc_msgSend_stret takes a hidden parameter for the returned structure's
address for the construction.  When the function signature is rewritten
for the inalloca passing, the return type is no longer marked as
indirect but rather inalloca stret.  This enhances the test for the
indirect return to check for that case as well.  This fixes the
incorrect return classification for Windows x86.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326362 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
test/CodeGenObjCXX/msabi-stret.mm [new file with mode: 0644]

index 1d346935de1068c5e1bc360993e87e317fb2d6c9..d1b07f86819e62ea84770e0df6f8c104bea974ad 100644 (file)
@@ -1479,7 +1479,8 @@ void ClangToLLVMArgMapping::construct(const ASTContext &Context,
 /***/
 
 bool CodeGenModule::ReturnTypeUsesSRet(const CGFunctionInfo &FI) {
-  return FI.getReturnInfo().isIndirect();
+  const auto &RI = FI.getReturnInfo();
+  return RI.isIndirect() || (RI.isInAlloca() && RI.getInAllocaSRet());
 }
 
 bool CodeGenModule::ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI) {
diff --git a/test/CodeGenObjCXX/msabi-stret.mm b/test/CodeGenObjCXX/msabi-stret.mm
new file mode 100644 (file)
index 0000000..765c238
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -Os -S -emit-llvm -o - %s -mdisable-fp-elim | FileCheck %s
+
+struct S {
+  S() = default;
+  S(const S &) {}
+};
+
+@interface I
++ (S)m:(S)s;
+@end
+
+S f() {
+  return [I m:S()];
+}
+
+// CHECK: declare dllimport void @objc_msgSend_stret(i8*, i8*, ...)
+// CHECK-NOT: declare dllimport void @objc_msgSend(i8*, i8*, ...)
+