Skip to content

Commit bd847cc

Browse files
committed
Un-revert r164907 and r164902 (+ follow-ups), 10.6 build fix to follow.
llvm-svn: 165988
1 parent 345b09c commit bd847cc

File tree

11 files changed

+153
-28
lines changed

11 files changed

+153
-28
lines changed

clang/include/clang/Basic/ObjCRuntime.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@ class ObjCRuntime {
157157
llvm_unreachable("bad kind");
158158
}
159159

160+
/// \brief Does this runtime supports optimized setter entrypoints?
161+
bool hasOptimizedSetter() const {
162+
switch (getKind()) {
163+
case MacOSX:
164+
return getVersion() >= VersionTuple(10, 8);
165+
case iOS:
166+
return (getVersion() >= VersionTuple(6));
167+
168+
default:
169+
return false;
170+
}
171+
}
172+
160173
/// Does this runtime allow the use of __weak?
161174
bool allowsWeak() const {
162175
return hasNativeWeak();
@@ -177,7 +190,7 @@ class ObjCRuntime {
177190
switch (getKind()) {
178191
case FragileMacOSX: return false;
179192
case MacOSX: return getVersion() >= VersionTuple(10, 8);
180-
case iOS: return false;
193+
case iOS: return getVersion() >= VersionTuple(6);
181194

182195
// This is really a lie, because some implementations and versions
183196
// of the runtime do not support ARC. Probably -fgnu-runtime

clang/lib/CodeGen/CGObjC.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,12 +1041,7 @@ static bool hasTrivialSetExpr(const ObjCPropertyImplDecl *PID) {
10411041
static bool UseOptimizedSetter(CodeGenModule &CGM) {
10421042
if (CGM.getLangOpts().getGC() != LangOptions::NonGC)
10431043
return false;
1044-
const TargetInfo &Target = CGM.getContext().getTargetInfo();
1045-
1046-
if (Target.getPlatformName() != "macosx")
1047-
return false;
1048-
1049-
return Target.getPlatformMinVersion() >= VersionTuple(10, 8);
1044+
return CGM.getLangOpts().ObjCRuntime.hasOptimizedSetter();
10501045
}
10511046

10521047
void
@@ -1106,7 +1101,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
11061101
llvm::Value *setOptimizedPropertyFn = 0;
11071102
llvm::Value *setPropertyFn = 0;
11081103
if (UseOptimizedSetter(CGM)) {
1109-
// 10.8 code and GC is off
1104+
// 10.8 and iOS 6.0 code and GC is off
11101105
setOptimizedPropertyFn =
11111106
CGM.getObjCRuntime()
11121107
.GetOptimizedPropertySetFunction(strategy.isAtomic(),

clang/lib/Driver/ToolChains.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
332332

333333
// Darwin doesn't support real static executables, don't link any runtime
334334
// libraries with -static.
335-
if (Args.hasArg(options::OPT_static))
335+
if (Args.hasArg(options::OPT_static) ||
336+
Args.hasArg(options::OPT_fapple_kext) ||
337+
Args.hasArg(options::OPT_mkernel))
336338
return;
337339

338340
// Reject -static-libgcc for now, we can deal with this when and if someone
@@ -676,7 +678,14 @@ void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
676678
llvm::sys::Path P(getDriver().ResourceDir);
677679
P.appendComponent("lib");
678680
P.appendComponent("darwin");
679-
P.appendComponent("libclang_rt.cc_kext.a");
681+
682+
// Use the newer cc_kext for iOS ARM after 6.0.
683+
if (!isTargetIPhoneOS() || isTargetIOSSimulator() ||
684+
!isIPhoneOSVersionLT(6, 0)) {
685+
P.appendComponent("libclang_rt.cc_kext.a");
686+
} else {
687+
P.appendComponent("libclang_rt.cc_kext_ios5.a");
688+
}
680689

681690
// For now, allow missing resource libraries to support developers who may
682691
// not have compiler-rt checked out or integrated into their build.
@@ -902,6 +911,25 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
902911
if (BoundArch)
903912
AddDeploymentTarget(*DAL);
904913

914+
// For iOS 6, undo the translation to add -static for -mkernel/-fapple-kext.
915+
// FIXME: It would be far better to avoid inserting those -static arguments,
916+
// but we can't check the deployment target in the translation code until
917+
// it is set here.
918+
if (isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) {
919+
for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) {
920+
Arg *A = *it;
921+
++it;
922+
if (A->getOption().getID() != options::OPT_mkernel &&
923+
A->getOption().getID() != options::OPT_fapple_kext)
924+
continue;
925+
assert(it != ie && "unexpected argument translation");
926+
A = *it;
927+
assert(A->getOption().getID() == options::OPT_static &&
928+
"missing expected -static argument");
929+
it = DAL->getArgs().erase(it);
930+
}
931+
}
932+
905933
// Validate the C++ standard library choice.
906934
CXXStdlibType Type = GetCXXStdlibType(*DAL);
907935
if (Type == ToolChain::CST_Libcxx) {

clang/lib/Driver/Tools.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,9 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
674674
ArgStringList &CmdArgs,
675675
bool KernelOrKext) const {
676676
const Driver &D = getToolChain().getDriver();
677-
llvm::Triple Triple = getToolChain().getTriple();
677+
// Get the effective triple, which takes into account the deployment target.
678+
std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
679+
llvm::Triple Triple(TripleStr);
678680

679681
// Select the ABI to use.
680682
//
@@ -759,8 +761,10 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
759761

760762
// Kernel code has more strict alignment requirements.
761763
if (KernelOrKext) {
762-
CmdArgs.push_back("-backend-option");
763-
CmdArgs.push_back("-arm-long-calls");
764+
if (Triple.getOS() != llvm::Triple::IOS || Triple.isOSVersionLT(6)) {
765+
CmdArgs.push_back("-backend-option");
766+
CmdArgs.push_back("-arm-long-calls");
767+
}
764768

765769
CmdArgs.push_back("-backend-option");
766770
CmdArgs.push_back("-arm-strict-align");
@@ -1697,7 +1701,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
16971701
}
16981702
// Note that these flags are trump-cards. Regardless of the order w.r.t. the
16991703
// PIC or PIE options above, if these show up, PIC is disabled.
1700-
if (Args.hasArg(options::OPT_mkernel))
1704+
llvm::Triple Triple(TripleStr);
1705+
if ((Args.hasArg(options::OPT_mkernel) ||
1706+
Args.hasArg(options::OPT_fapple_kext)) &&
1707+
(Triple.getOS() != llvm::Triple::IOS ||
1708+
Triple.isOSVersionLT(6)))
17011709
PICDisabled = true;
17021710
if (Args.hasArg(options::OPT_static))
17031711
PICDisabled = true;
@@ -3690,7 +3698,10 @@ void darwin::CC1::AddCC1Args(const ArgList &Args,
36903698
CheckCodeGenerationOptions(D, Args);
36913699

36923700
// Derived from cc1 spec.
3693-
if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) &&
3701+
if ((!Args.hasArg(options::OPT_mkernel) ||
3702+
(getDarwinToolChain().isTargetIPhoneOS() &&
3703+
!getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) &&
3704+
!Args.hasArg(options::OPT_static) &&
36943705
!Args.hasArg(options::OPT_mdynamic_no_pic))
36953706
CmdArgs.push_back("-fPIC");
36963707

@@ -4144,9 +4155,11 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
41444155
CmdArgs.push_back("-force_cpusubtype_ALL");
41454156

41464157
if (getToolChain().getTriple().getArch() != llvm::Triple::x86_64 &&
4147-
(Args.hasArg(options::OPT_mkernel) ||
4148-
Args.hasArg(options::OPT_static) ||
4149-
Args.hasArg(options::OPT_fapple_kext)))
4158+
(((Args.hasArg(options::OPT_mkernel) ||
4159+
Args.hasArg(options::OPT_fapple_kext)) &&
4160+
(!getDarwinToolChain().isTargetIPhoneOS() ||
4161+
getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) ||
4162+
Args.hasArg(options::OPT_static)))
41504163
CmdArgs.push_back("-static");
41514164

41524165
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@@ -4507,7 +4520,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
45074520
} else if (getDarwinToolChain().isTargetIPhoneOS()) {
45084521
if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
45094522
CmdArgs.push_back("-lcrt1.o");
4510-
else
4523+
else if (getDarwinToolChain().isIPhoneOSVersionLT(6, 0))
45114524
CmdArgs.push_back("-lcrt1.3.1.o");
45124525
} else {
45134526
if (getDarwinToolChain().isMacosxVersionLT(10, 5))

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9770,11 +9770,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
97709770

97719771
switch (ConvTy) {
97729772
case Compatible:
9773-
DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
9774-
9775-
// XXX here with forced compatible cast
9776-
9777-
return false;
9773+
DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
9774+
return false;
97789775

97799776
case PointerToInt:
97809777
DiagKind = diag::ext_typecheck_convert_pointer_int;
@@ -9857,7 +9854,6 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
98579854
DiagKind = diag::err_arc_weak_unavailable_assign;
98589855
break;
98599856
case Incompatible:
9860-
// XXX here
98619857
DiagKind = diag::err_typecheck_convert_incompatible;
98629858
ConvHints.tryToFixConversion(SrcExpr, SrcType, DstType, *this);
98639859
MayHaveConvFixit = true;

clang/runtime/compiler-rt/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ RuntimeDirs :=
7474
ifeq ($(OS),Darwin)
7575
RuntimeDirs += darwin
7676
RuntimeLibrary.darwin.Configs := \
77-
eprintf.a 10.4.a osx.a cc_kext.a \
77+
eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
7878
asan_osx.a asan_osx_dynamic.dylib \
79-
profile_osx.a
79+
profile_osx.a profile_ios.a
8080
endif
8181

8282
# On Linux, include a library which has all the runtime functions.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %clang_cc1 %s -emit-llvm -fobjc-runtime=ios-6.0.0 -triple thumbv7-apple-ios6.0.0 -o - | FileCheck %s
2+
// rdar://11915017
3+
4+
@interface I
5+
// void objc_setProperty_nonatomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
6+
// objc_setProperty(..., NO, NO)
7+
@property (nonatomic, retain) id nonatomicProperty;
8+
9+
// void objc_setProperty_nonatomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
10+
// objc_setProperty(..., NO, YES)
11+
@property (nonatomic, copy) id nonatomicPropertyCopy;
12+
13+
// void objc_setProperty_atomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
14+
// objc_setProperty(..., YES, NO)
15+
@property (retain) id atomicProperty;
16+
17+
// void objc_setProperty_atomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
18+
// objc_setProperty(..., YES, YES)
19+
@property (copy) id atomicPropertyCopy;
20+
@end
21+
22+
@implementation I
23+
@synthesize nonatomicProperty;
24+
@synthesize nonatomicPropertyCopy;
25+
@synthesize atomicProperty;
26+
@synthesize atomicPropertyCopy;
27+
@end
28+
29+
// CHECK: call arm_aapcscc void @objc_setProperty_nonatomic
30+
// CHECK: call arm_aapcscc void @objc_setProperty_nonatomic_copy
31+
// CHECK: call arm_aapcscc void @objc_setProperty_atomic
32+
// CHECK: call arm_aapcscc void @objc_setProperty_atomic_copy
33+

clang/test/CodeGenObjC/optimized-setter.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.8.0 -o - | FileCheck %s
1+
// RUN: %clang_cc1 %s -emit-llvm -fobjc-runtime=macosx-10.8 -triple x86_64-apple-macosx10.8.0 -o - | FileCheck %s
2+
// RUN: %clang_cc1 %s -emit-llvm -fobjc-runtime=ios-6.0.0 -triple x86_64-apple-ios6.0.0 -o - | FileCheck %s
23
// rdar://10179974
34

45
@interface I
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 %s -emit-llvm -fobjc-runtime=macosx-10.6.0 -triple x86_64-apple-macosx10.6.0 -o - | FileCheck %s
2+
// rdar://11858187
3+
4+
@interface I
5+
// void objc_setProperty_nonatomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
6+
// objc_setProperty(..., NO, NO)
7+
@property (nonatomic, retain) id nonatomicProperty;
8+
9+
// void objc_setProperty_nonatomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
10+
// objc_setProperty(..., NO, YES)
11+
@property (nonatomic, copy) id nonatomicPropertyCopy;
12+
13+
// void objc_setProperty_atomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
14+
// objc_setProperty(..., YES, NO)
15+
@property (retain) id atomicProperty;
16+
17+
// void objc_setProperty_atomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
18+
// objc_setProperty(..., YES, YES)
19+
@property (copy) id atomicPropertyCopy;
20+
@end
21+
22+
@implementation I
23+
@synthesize nonatomicProperty;
24+
@synthesize nonatomicPropertyCopy;
25+
@synthesize atomicProperty;
26+
@synthesize atomicPropertyCopy;
27+
@end
28+
29+
// CHECK-NOT: call void @objc_setProperty_nonatomic
30+
// CHECK-NOT: call void @objc_setProperty_nonatomic_copy
31+
// CHECK-NOT: call void @objc_setProperty_atomic
32+
// CHECK-NOT: call void @objc_setProperty_atomic_copy

clang/test/Driver/darwin-ld.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@
122122
// RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log
123123
// LINK_NO_CRT1-NOT: crt
124124

125+
// RUN: %clang -target armv7-apple-ios6.0 -miphoneos-version-min=6.0 -### %t.o 2> %t.log
126+
// RUN: FileCheck -check-prefix=LINK_NO_IOS_CRT1 %s < %t.log
127+
// LINK_NO_IOS_CRT1-NOT: crt
128+
125129
// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log
126130
// RUN: FileCheck -check-prefix=LINK_PG %s < %t.log
127131
// LINK_PG: -lgcrt1.o

clang/test/Driver/pic.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@
9393
// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC1
9494
// RUN: %clang -c %s -target i386-apple-darwin -mdynamic-no-pic -fPIC -### 2>&1 \
9595
// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC2
96+
97+
// Checks for ARM
98+
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -### 2>&1 \
99+
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
100+
// RUN: %clang -c %s -target armv7-apple-ios -mkernel -miphoneos-version-min=6.0.0 -### 2>&1 \
101+
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
102+
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=5.0.0 -### 2>&1 \
103+
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
104+
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \
105+
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC

0 commit comments

Comments
 (0)