r306444 - CodeGen: load indirect ObjC ARC arguments in prologue
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 27 11:37:51 PDT 2017
Author: compnerd
Date: Tue Jun 27 11:37:51 2017
New Revision: 306444
URL: http://llvm.org/viewvc/llvm-project?rev=306444&view=rev
Log:
CodeGen: load indirect ObjC ARC arguments in prologue
When generating a prologue, add loads for ARC arguments passed
indirectly.
Patch by Dave Lee!
Added:
cfe/trunk/test/CodeGenObjCXX/arc-indirect.mm
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=306444&r1=306443&r2=306444&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Jun 27 11:37:51 2017
@@ -1860,6 +1860,10 @@ void CodeGenFunction::EmitParmDecl(const
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) {
Added: cfe/trunk/test/CodeGenObjCXX/arc-indirect.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-indirect.mm?rev=306444&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/arc-indirect.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/arc-indirect.mm Tue Jun 27 11:37:51 2017
@@ -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)
More information about the cfe-commits
mailing list