[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 16:42:54 PST 2018


compnerd created this revision.
compnerd added reviewers: rjmccall, rnk.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D43842

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenObjCXX/msabi-stret.mm


Index: test/CodeGenObjCXX/msabi-stret.mm
===================================================================
--- /dev/null
+++ test/CodeGenObjCXX/msabi-stret.mm
@@ -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 &) {}
+};
+
+ at interface I
++ (S)m:(S)s;
+ at 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*, ...)
+
Index: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1479,7 +1479,8 @@
 /***/
 
 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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43842.136188.patch
Type: text/x-patch
Size: 1069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180228/b98a76bd/attachment.bin>


More information about the cfe-commits mailing list