35 lines · plain
1; Check that we internalize external constant if it is accessed2; purely by non-volatile loads.3; RUN: opt -thinlto-bc %s -o %t-main4; RUN: opt -thinlto-bc %p/Inputs/import-ro-constant-foo.ll -o %t-foo5; RUN: opt -thinlto-bc %p/Inputs/import-ro-constant-bar.ll -o %t-bar6; 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 \12; RUN: -r=%t-bar,foo,13; RUN: llvm-dis %t-out.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT14; RUN: llvm-dis %t-out.1.4.opt.bc -o - | FileCheck %s --check-prefix=OPT15 16; IMPORT: @foo = internal local_unnamed_addr constant i32 21, align 4 #017; IMPORT: attributes #0 = { "thinlto-internalize" }18; OPT: i32 @main()19; OPT-NEXT: entry:20; OPT-NEXT: ret i32 4221 22source_filename = "main.c"23target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"24target triple = "x86_64-unknown-linux-gnu"25 26@foo = external dso_local local_unnamed_addr constant i32, align 427define dso_local i32 @main() local_unnamed_addr {28entry:29 %0 = load i32, ptr @foo, align 430 %call = tail call i32 @_Z3barv()31 %add = add nsw i32 %call, %032 ret i32 %add33}34declare dso_local i32 @_Z3barv() local_unnamed_addr35