[PATCH] D34580: [CodeGen][ObjC] Load indirect ARC arguments in prolog

Dave Lee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 10:52:16 PDT 2017


kastiglione updated this revision to Diff 103994.
kastiglione added a comment.

CHECK load and call


https://reviews.llvm.org/D34580

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGenObjCXX/arc-indirect.mm


Index: test/CodeGenObjCXX/arc-indirect.mm
===================================================================
--- /dev/null
+++ test/CodeGenObjCXX/arc-indirect.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=gnustep -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-GNUSTEP %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=macosx -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=ios -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+
+// non trivially copyable, forces inalloca
+struct S {
+  S(const S &s) {}
+};
+
+ at interface C
+ at end
+ at implementation C
+- (void)object:(id)obj struct:(S)s {
+}
+ at end
+
+// CHECK-GNUSTEP: define internal void @_i_C__object_struct_(<{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK-DARWIN: define internal void @"\01-[C object:struct:]"(<{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK: %obj = getelementptr inbounds <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>, <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* %0, i32 0, i32 2
+// CHECK: %1 = load i8*, i8** %obj, align 4
+// CHECK: call void @objc_storeStrong(i8** %obj, i8* %1)
Index: lib/CodeGen/CGDecl.cpp
===================================================================
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1860,6 +1860,10 @@
         lt = Qualifiers::OCL_ExplicitNone;
       }
 
+      // Load objects passed indirectly.
+      if (Arg.isIndirect() && !ArgVal)
+        ArgVal = Builder.CreateLoad(DeclPtr);
+
       if (lt == Qualifiers::OCL_Strong) {
         if (!isConsumed) {
           if (CGM.getCodeGenOpts().OptimizationLevel == 0) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34580.103994.patch
Type: text/x-patch
Size: 1885 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170626/6f774e54/attachment-0001.bin>


More information about the cfe-commits mailing list