[llvm-dev] Link Module with blocks cause module destruction assert

xiuli pan via llvm-dev llvm-dev at lists.llvm.org
Fri May 6 00:17:04 PDT 2016


Hi guys,

 

We are using a module as library and link the source code in the library and
when the source code has some blocks there are some bugs with the global
values, caused assert when deleting module in debug version. 

 

Here is llvm ir for global values before link and after link:

Before link:

@_NSConcreteGlobalBlock = external global i8*

@.str = private unnamed_addr addrspace(2) constant [9 x i8] c"i12@?0i8\00",
align 1

@__block_descriptor_tmp = internal constant { i64, i64, i8 addrspace(2)*, i8
addrspace(2)* } { i64 0, i64 32, i8 addrspace(2)* getelementptr inbounds ([9
x i8], [9 x i8] addrspace(2)* @.str, i32 0, i32 0), i8 addrspace(2)* null }

@__block_literal_global = internal constant { i8**, i32, i32, i8*,
%struct.__block_descriptor* } { i8** @_NSConcreteGlobalBlock, i32
1342177280, i32 0, i8* bitcast (i32 (i8*, i32)* @__test_block_invoke to
i8*), %struct.__block_descriptor* bitcast ({ i64, i64, i8 addrspace(2)*, i8
addrspace(2)* }* @__block_descriptor_tmp to %struct.__block_descriptor*) },
align 8

 

After link:

@__block_literal_global = internal constant { i8**, i32, i32, i8*,
%struct.__block_descriptor* } { i8** @_NSConcreteGlobalBlock, i32
1342177280, i32 0, i8* bitcast (i32 (i8*, i32)* @__test_block_invoke to
i8*), %struct.__block_descriptor* bitcast ({ i64, i64, i8 addrspace(2)*, i8
addrspace(2)* }* @__block_descriptor_tmp to %struct.__block_descriptor*) },
align 8

@_NSConcreteGlobalBlock = external global i8*

@__block_descriptor_tmp = internal constant { i64, i64, i8 addrspace(2)*, i8
addrspace(2)* } { i64 0, i64 32, i8 addrspace(2)* getelementptr inbounds ([9
x i8], [9 x i8] addrspace(2)* @.str, i32 0, i32 0), i8 addrspace(2)* null }

@.str = private unnamed_addr addrspace(2) constant [9 x i8] c"i12@?0i8\00",
align 1

 

As you can see after link, @__block_literal_global depends on values
declared after it.

 

I have run some tests in gdb and find that this was caused from IRMover and
resulted in MapValue. It will always just make new declaration no matter if
the global value depends on some other values, and will map those value
afterwards.

 

I have reported a bug in https://llvm.org/bugs/show_bug.cgi?id=27651. If
this is a bug or behavior on purpose?

 

Thanks

Xiuli

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160506/ed1fc412/attachment.html>


More information about the llvm-dev mailing list