36 lines · plain
1; Test to ensure that we import a single copy of a global variable. This is2; important when we link in an object file twice, which is normally works when3; all symbols have either weak or internal linkage. If we import an internal4; global variable twice it will get promoted in each module, and given the same5; name as the IR hash will be identical, resulting in multiple defs when linking.6; RUN: opt -module-summary %s -o %t1.bc7; RUN: opt -module-summary %p/Inputs/globals-import.ll -o %t2.bc8; RUN: opt -module-summary %p/Inputs/globals-import.ll -o %t2b.bc9; RUN: llvm-lto -thinlto-action=thinlink %t1.bc %t2.bc %t2b.bc -o %t3.index.bc10 11; RUN: llvm-lto -thinlto-action=import %t1.bc -thinlto-index=%t3.index.bc12; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck --check-prefix=IMPORT %s13; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.index.bc14; RUN: llvm-lto -thinlto-action=promote %t2b.bc -thinlto-index=%t3.index.bc15; RUN: llvm-dis %t2.bc.thinlto.promoted.bc -o - | FileCheck --check-prefix=PROMOTE1 %s16; RUN: llvm-dis %t2b.bc.thinlto.promoted.bc -o - | FileCheck --check-prefix=PROMOTE2 %s17 18; IMPORT: @baz.llvm.0 = internal constant i32 10, align 419 20; PROMOTE1: @baz.llvm.0 = hidden constant i32 10, align 421; 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 425; PROMOTE2: define available_externally i32 @foo() {26 27target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-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 %135}36