1; This test ensures that we drop the preempted copy of @f/@g from %t2.bc from their 2; comdats after making it available_externally. If not we would get a 3; verification error. g_internal/g_private are changed to available_externally 4; as well since it is in the same comdat of g. 5; RUN: opt -module-summary %s -o %t1.bc 6; RUN: opt -module-summary %p/Inputs/linkonce_resolution_comdat.ll -o %t2.bc 7; RUN: llvm-lto -thinlto-action=run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -exported-symbol=f -exported-symbol=g -exported-symbol=h -thinlto-save-temps=%t3. 8 9; RUN: llvm-dis %t3.0.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT1 10; RUN: llvm-dis %t3.1.3.imported.bc -o - | FileCheck %s --check-prefix=IMPORT2 11; Copy from first module is prevailing and converted to weak_odr, copy 12; from second module is preempted and converted to available_externally and 13; removed from comdat. 14; IMPORT1: @g_private = private global i32 43, comdat($g) 15; IMPORT1: define weak_odr i32 @f(ptr %0) unnamed_addr [[ATTR:#[0-9]+]] comdat { 16; IMPORT1: define weak_odr i32 @g() unnamed_addr [[ATTR]] comdat { 17; IMPORT1: define internal void @g_internal() unnamed_addr comdat($g) { 18 19; IMPORT2: @g_private = available_externally dso_local global i32 41{{$}} 20; IMPORT2: define available_externally i32 @f(ptr %0) unnamed_addr [[ATTR:#[0-9]+]] { 21; IMPORT2: define available_externally i32 @g() unnamed_addr [[ATTR]] { 22; IMPORT2: define available_externally dso_local void @g_internal() unnamed_addr { 23 24; CHECK-DAG: attributes [[ATTR]] = { norecurse nounwind } 25 26; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM1 27; NM1: W f 28; NM1: W g 29 30; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s --check-prefix=NM2 31; f() would have been turned into available_externally since it is preempted, 32; and inlined into h() 33; NM2-NOT: f 34; NM2-NOT: g 35 36target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 37target triple = "x86_64-unknown-linux-gnu" 38 39$f = comdat any 40$g = comdat any 41 42@g_private = private global i32 43, comdat($g) 43 44define linkonce_odr i32 @f(ptr) unnamed_addr comdat { 45 ret i32 43 46} 47 48define linkonce_odr i32 @g() unnamed_addr comdat { 49 ret i32 43 50} 51 52define internal void @g_internal() unnamed_addr comdat($g) { 53 ret void 54} 55