1; Test to ensure that we import a single copy of a global variable. This is 2; important when we link in an object file twice, which is normally works when 3; all symbols have either weak or internal linkage. If we import an internal 4; global variable twice it will get promoted in each module, and given the same 5; name as the IR hash will be identical, resulting in multiple defs when linking. 6; RUN: opt -module-summary %s -o %t1.bc 7; RUN: opt -module-summary %p/Inputs/globals-import.ll -o %t2.bc 8; RUN: opt -module-summary %p/Inputs/globals-import.ll -o %t2b.bc 9; RUN: llvm-lto -thinlto-action=thinlink %t1.bc %t2.bc %t2b.bc -o %t3.index.bc 10 11; RUN: llvm-lto -thinlto-action=import %t1.bc -thinlto-index=%t3.index.bc 12; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck --check-prefix=IMPORT %s 13; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.index.bc 14; RUN: llvm-lto -thinlto-action=promote %t2b.bc -thinlto-index=%t3.index.bc 15; RUN: llvm-dis %t2.bc.thinlto.promoted.bc -o - | FileCheck --check-prefix=PROMOTE1 %s 16; RUN: llvm-dis %t2b.bc.thinlto.promoted.bc -o - | FileCheck --check-prefix=PROMOTE2 %s 17 18; IMPORT: @baz.llvm.0 = available_externally hidden constant i32 10, align 4 19 20; PROMOTE1: @baz.llvm.0 = hidden constant i32 10, align 4 21; PROMOTE1: define weak_odr i32 @foo() { 22 23; Second copy of IR object should not have any symbols imported/promoted. 24; PROMOTE2: @baz = internal constant i32 10, align 4 25; PROMOTE2: define available_externally i32 @foo() { 26 27target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 28target triple = "x86_64-pc-linux-gnu" 29 30declare i32 @foo() 31 32define i32 @main() local_unnamed_addr { 33 %1 = call i32 @foo() 34 ret i32 %1 35} 36