When compiling a constexpr NSString initialized with an objective-c string literal, CodeGen currently emits objc_storeStrong on an uninitialized alloca, which causes a crash:
constexpr NSString *S = @"abc";
%S = alloca %0*, align 8 %0 = bitcast %0** %S to i8** ; this points to uninitialized memory call void @objc_storeStrong(i8** %0, i8* bitcast (%struct.__NSConstantString_tag* @_unnamed_cfstring_ to i8*)) #1
This patch fixes the crash by directly storing the pointer to the __NSConstantString_tag for the string into the allocated alloca. The rationale for this change is that retain or release on an Objective-c string literal (or anything used to initialize a constexpr variable) has no effect and therefore objc_storeStrong isn't needed in this case.
rdar://problem/28562009
These two cases are actually identical in behavior (because __autoreleased variables don't actually own their current value). I think I prefer the second way of writing it.