1; RUN: opt -module-summary %s -o %t1.o
2; RUN: opt -module-summary %p/Inputs/common_thinlto.ll -o %t2.o
3
4; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
5; RUN:    --plugin-opt=save-temps \
6; RUN:    --plugin-opt=thinlto \
7; RUN:    -m elf_x86_64 \
8; RUN:    -shared %t1.o %t2.o -o %t3
9
10; RUN: llvm-dis %t1.o.2.internalize.bc -o - | FileCheck %s --check-prefix=INTERNALIZE
11; We should not have internalized P, and it should still be common.
12; INTERNALIZE: @P = common global
13
14; RUN: llvm-dis %t1.o.4.opt.bc -o - | FileCheck %s --check-prefix=OPT
15; bar should still exist (if we had internalized P it would look dead).
16; OPT: @bar
17
18; RUN: llvm-nm %t3 | FileCheck %s --check-prefix=NM
19; NM: bar
20
21source_filename = "common1.c"
22target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25@P = common global i8* (...)* null, align 8
26
27define i32 @main() {
28entry:
29  store i8* (...)* bitcast (i8* ()* @bar to i8* (...)*), i8* (...)** @P, align 8
30  %call = call i32 (...) @foo()
31  ret i32 0
32}
33
34declare i32 @foo(...)
35
36define internal i8* @bar() {
37entry:
38  ret i8* null
39}
40