diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-06-27 18:37:51 +0000 |
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-06-27 18:37:51 +0000 |
| commit | da6784e8ff41c12e704169149ca9c64901255314 (patch) | |
| tree | 61c7a6366e4d7334dd1bcc9b0d9133edf018eff6 | |
| parent | 5ddd2e589995d996689e5c7b1c5372bda4a70493 (diff) | |
| download | bcm5719-llvm-da6784e8ff41c12e704169149ca9c64901255314.tar.gz bcm5719-llvm-da6784e8ff41c12e704169149ca9c64901255314.zip | |
CodeGen: load indirect ObjC ARC arguments in prologue
When generating a prologue, add loads for ARC arguments passed
indirectly.
Patch by Dave Lee!
llvm-svn: 306444
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenObjCXX/arc-indirect.mm | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index ccd3b8d513b..4b656ea4a87 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1860,6 +1860,10 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg, 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) { diff --git a/clang/test/CodeGenObjCXX/arc-indirect.mm b/clang/test/CodeGenObjCXX/arc-indirect.mm new file mode 100644 index 00000000000..2684e82e2e3 --- /dev/null +++ b/clang/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) {} +}; + +@interface C +@end +@implementation C +- (void)object:(id)obj struct:(S)s { +} +@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) |

