Summary: When linking a regular LTO module, if it has any non-prevailing values (dropped to available_externally) in comdats, we need to do more than just remove those values from their comdat. We also remove all values from that comdat, so as to avoid leaving an incomplete comdat. This is necessary in case we are compiling in mixed regular and ThinLTO mode, since the resulting regularLTO native object is always linked into the final binary first. We need to prevent the linker from selecting an incomplete comdat that was not the prevailing copy. Fixes PR32980. Reviewers: pcc, rafael Subscribers: mehdi_amini, david2050, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D34803 llvm-svn: 306826
24 lines
836 B
LLVM
24 lines
836 B
LLVM
; ModuleID = 'comdat-mixed-lto1.o'
|
|
source_filename = "comdat-mixed-lto1.cpp"
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
%"class.Test::ptr" = type { i32 }
|
|
|
|
$C = comdat any
|
|
|
|
@C = linkonce_odr global %"class.Test::ptr" zeroinitializer, comdat, align 4
|
|
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init, i8* bitcast (%"class.Test::ptr"* @C to i8*) }]
|
|
|
|
define void @testglobfunc() #1 section ".text.startup" comdat($C) {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: noinline uwtable
|
|
define internal void @__cxx_global_var_init() #1 section ".text.startup" comdat($C) {
|
|
entry:
|
|
store i32 0, i32* getelementptr inbounds (%"class.Test::ptr", %"class.Test::ptr"* @C, i32 0, i32 0), align 4
|
|
ret void
|
|
}
|