1 ; This test ensures that when linkonce_odr + unnamed_addr symbols & linkonce_odr
2 ; + local_unnamed_addr constants get promoted to weak symbols, we preserves the
3 ; auto hide property when possible.
5 ; RUN: opt -module-summary %s -o %t.bc
6 ; RUN: opt -module-summary %p/Inputs/linkonce_odr_unnamed_addr.ll -o %t2.bc
8 ; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
9 ; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s
11 ; RUN: llvm-lto2 run -save-temps -o %t6.bc %t.bc %t2.bc \
12 ; RUN: -r=%t.bc,linkonceodrunnamedconst,p \
13 ; RUN: -r=%t.bc,linkonceodrunnamed,p \
14 ; RUN: -r=%t.bc,linkonceodrlocalunnamedconst,p \
15 ; RUN: -r=%t.bc,linkonceodrlocalunnamed,p \
16 ; RUN: -r=%t.bc,odrunnamed,p \
17 ; RUN: -r=%t2.bc,linkonceodrunnamedconst \
18 ; RUN: -r=%t2.bc,linkonceodrunnamed \
19 ; RUN: -r=%t2.bc,linkonceodrlocalunnamedconst \
20 ; RUN: -r=%t2.bc,linkonceodrlocalunnamed \
21 ; RUN: -r=%t2.bc,odrunnamed
22 ; RUN: llvm-dis %t6.bc.1.1.promote.bc -o - | FileCheck %s
24 ; Now test when one module does not have a summary. In that case we must be
25 ; conservative and not auto hide.
26 ; RUN: opt %p/Inputs/linkonce_odr_unnamed_addr.ll -o %t4.bc
27 ; Check new LTO API (old LTO API does not detect this case).
28 ; RUN: llvm-lto2 run -save-temps -o %t6.bc %t.bc %t4.bc \
29 ; RUN: -r=%t.bc,linkonceodrunnamedconst,p \
30 ; RUN: -r=%t.bc,linkonceodrunnamed,p \
31 ; RUN: -r=%t.bc,linkonceodrlocalunnamedconst,p \
32 ; RUN: -r=%t.bc,linkonceodrlocalunnamed,p \
33 ; RUN: -r=%t.bc,odrunnamed,p \
34 ; RUN: -r=%t4.bc,linkonceodrunnamedconst \
35 ; RUN: -r=%t4.bc,linkonceodrunnamed \
36 ; RUN: -r=%t4.bc,linkonceodrlocalunnamedconst \
37 ; RUN: -r=%t4.bc,linkonceodrlocalunnamed \
38 ; RUN: -r=%t4.bc,odrunnamed
39 ; RUN: llvm-dis %t6.bc.1.1.promote.bc -o - | FileCheck %s --check-prefix=NOSUMMARY
41 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
42 target triple = "x86_64-grtev4-linux-gnu"
44 ; In this case all copies are linkonce_odr, so it may be hidden.
45 ; CHECK: @linkonceodrunnamedconst = weak_odr hidden unnamed_addr constant i32 0
46 ; CHECK: @linkonceodrunnamed = weak_odr hidden unnamed_addr global i32 0
47 ; CHECK: @linkonceodrlocalunnamedconst = weak_odr hidden local_unnamed_addr constant i32 0
48 ; NOSUMMARY: @linkonceodrunnamedconst = weak_odr unnamed_addr constant i32 0
49 ; NOSUMMARY: @linkonceodrunnamed = weak_odr unnamed_addr global i32 0
50 ; NOSUMMARY: @linkonceodrlocalunnamedconst = weak_odr local_unnamed_addr constant i32 0
51 @linkonceodrunnamedconst = linkonce_odr unnamed_addr constant i32 0
52 @linkonceodrunnamed = linkonce_odr unnamed_addr global i32 0
53 @linkonceodrlocalunnamedconst = linkonce_odr local_unnamed_addr constant i32 0
55 ; In this case, the other copy was weak_odr, so it may not be hidden.
56 ; CHECK: @odrunnamed = weak_odr unnamed_addr constant i32 0
57 ; NOSUMMARY: @odrunnamed = weak_odr unnamed_addr constant i32 0
58 @odrunnamed = linkonce_odr unnamed_addr constant i32 0
60 ; local_unnamed_addr globals cannot be hidden.
61 ; CHECK: @linkonceodrlocalunnamed = weak_odr local_unnamed_addr global i32 0
62 ; NOSUMMARY: @linkonceodrlocalunnamed = weak_odr local_unnamed_addr global i32 0
63 @linkonceodrlocalunnamed = linkonce_odr local_unnamed_addr global i32 0