https://llvm.org/bugs/show_bug.cgi?id=27651

            Bug ID: 27651
           Summary: Link will change global value order
           Product: libraries
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Linker
          Assignee: unassignedb...@nondot.org
          Reporter: xiuli...@outlook.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

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 value.
In debug version the ~Module will assert.

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 the global valve orders change, the dependency of these global values are
messed.

It seems the bug was caused by ModuleLinker::linkIfNeeded with a recursion call
but with a wrong order.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to