1 ; Check that we internalize external constant if it is accessed
2 ; purely by non-volatile loads.
3 ; RUN: opt -thinlto-bc %s -o %t-main
4 ; RUN: opt -thinlto-bc %p/Inputs/import-ro-constant-foo.ll -o %t-foo
5 ; RUN: opt -thinlto-bc %p/Inputs/import-ro-constant-bar.ll -o %t-bar
6 ; RUN: llvm-lto2 run -save-temps -o %t-out %t-main %t-foo %t-bar \
7 ; RUN: -r=%t-foo,foo,pl \
8 ; RUN: -r=%t-main,main,plx \
9 ; RUN: -r=%t-main,_Z3barv,l \
10 ; RUN: -r=%t-main,foo, \
11 ; RUN: -r=%t-bar,_Z3barv,pl \
13 ; RUN: llvm-dis %t-out.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
14 ; RUN: llvm-dis %t-out.1.4.opt.bc -o - | FileCheck %s --check-prefix=OPT
16 ; IMPORT: @foo = internal local_unnamed_addr constant i32 21, align 4 #0
17 ; IMPORT: attributes #0 = { "thinlto-internalize" }
20 ; OPT-NEXT: ret i32 42
22 source_filename = "main.c"
23 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
24 target triple = "x86_64-unknown-linux-gnu"
26 @foo = external dso_local local_unnamed_addr constant i32, align 4
27 define dso_local i32 @main() local_unnamed_addr {
29 %0 = load i32, ptr @foo, align 4
30 %call = tail call i32 @_Z3barv()
31 %add = add nsw i32 %call, %0
34 declare dso_local i32 @_Z3barv() local_unnamed_addr