[PATCH] D20045: [ObjC][CodeGen] Remove an assert that is no longer correct.

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Thu May 12 13:10:17 PDT 2016


ahatanak added a comment.

In http://reviews.llvm.org/D20045#425903, @manmanren wrote:

> After r231508 made changes to promote constant temporaries to globals, the assert fires when a std::initializer_list is constructed using Objective-C string literals.
>
> --> Can you explain the code path after r231508 for your example? Will r231508 change the code path if we start with a global?
>  r231508 seems to change the behavior constant temporaries only.


I think your question is about the following case where initializer_list is used to initialize a global variable?

const std::vector<NSString*> CfgFiles = {@"Test0", @"Test1", @"Test2", @"Test3"};

This is not different from the case where the vector is declared inside a function. In both cases, a temporary std::initializer_list is created and passed to std::vector's constructor. 
r231508 made changes to create a global array of strings (@.ref.tmp in the IR shown below).

@.ref.tmp = private constant [4 x %0*] [%0* bitcast (%struct.__NSConstantString_tag* @_unnamed_cfstring_ to %0*), %0* bitcast (%struct.__NSConstantString_tag* @_unnamed_cfstring_.2 to %0*), %0* bitcast (%struct.__NSConstantString_tag* @_unnamed_cfstring_.4 to %0*), %0* bitcast (%struct.__NSConstantString_tag* @_unnamed_cfstring_.6 to %0*)], align 8
...
%agg.tmp = alloca %"class.std::initializer_list", align 8 ; temporary std::initializer_list
%__begin_ = getelementptr inbounds %"class.std::initializer_list", %"class.std::initializer_list"* %agg.tmp, i32 0, i32 0
store %0** getelementptr inbounds ([4 x %0*], [4 x %0*]* @.ref.tmp, i64 0, i64 0), %0*** %__begin_, align 8, !tbaa !7 ; std::initializer_list holds a pointer to the array.


http://reviews.llvm.org/D20045





More information about the cfe-commits mailing list