[cfe-commits] r102219 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/CodeGen/CodeGenModule.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Apr 23 15:33:39 PDT 2010
Author: fjahanian
Date: Fri Apr 23 17:33:39 2010
New Revision: 102219
URL: http://llvm.org/viewvc/llvm-project?rev=102219&view=rev
Log:
More -fno-constant-cfstrings API work.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=102219&r1=102218&r2=102219&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Apr 23 17:33:39 2010
@@ -345,6 +345,12 @@
return "__OBJC,__cstring_object,regular,no_dead_strip";
}
+ /// getNSStringNonFragileABISection - Return the section to use for
+ /// NSString literals, or 0 if no special section is used (NonFragile ABI).
+ virtual const char *getNSStringNonFragileABISection() const {
+ return "__DATA, __objc_stringobj, regular, no_dead_strip";
+ }
+
/// isValidSectionSpecifier - This is an optional hook that targets can
/// implement to perform semantic checking on attribute((section("foo")))
/// specifiers. In this case, "foo" is passed in to be checked. If the
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=102219&r1=102218&r2=102219&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Apr 23 17:33:39 2010
@@ -1610,12 +1610,14 @@
llvm::Constant::getNullValue(llvm::Type::getInt32Ty(VMContext));
llvm::Constant *Zeros[] = { Zero, Zero };
- // If we don't already have it, get __NSConstantStringClassReference.
+ // If we don't already have it, get _NSConstantStringClassReference.
if (!NSConstantStringClassRef) {
const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = llvm::ArrayType::get(Ty, 0);
- llvm::Constant *GV = CreateRuntimeVariable(Ty,
- "__NSConstantStringClassReference");
+ llvm::Constant *GV = CreateRuntimeVariable(Ty,
+ Features.ObjCNonFragileABI ?
+ "OBJC_CLASS_$_NSConstantString" :
+ "_NSConstantStringClassReference");
// Decay array -> ptr
NSConstantStringClassRef =
llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2);
@@ -1666,7 +1668,10 @@
llvm::GlobalVariable::PrivateLinkage, C,
"_unnamed_nsstring_");
// FIXME. Fix section.
- if (const char *Sect = getContext().Target.getNSStringSection())
+ if (const char *Sect =
+ Features.ObjCNonFragileABI
+ ? getContext().Target.getNSStringNonFragileABISection()
+ : getContext().Target.getNSStringSection())
GV->setSection(Sect);
Entry.setValue(GV);
More information about the cfe-commits
mailing list