1 ; Check that we optimize out writeonly variables and corresponding stores.
2 ; This test uses llvm-lto2
4 ; RUN: opt -module-summary %s -o %t1.bc
5 ; RUN: opt -module-summary %p/Inputs/index-const-prop.ll -o %t2.bc
6 ; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \
7 ; RUN: -r=%t2.bc,foo,pl \
8 ; RUN: -r=%t2.bc,bar,pl \
9 ; RUN: -r=%t2.bc,baz,pl \
10 ; RUN: -r=%t2.bc,rand, \
11 ; RUN: -r=%t2.bc,gBar,pl \
12 ; RUN: -r=%t1.bc,main,plx \
13 ; RUN: -r=%t1.bc,baz, \
14 ; RUN: -r=%t1.bc,gBar, \
16 ; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
17 ; RUN: llvm-dis %t3.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN
18 ; Check that gFoo and gBar were eliminated from source module together
19 ; with corresponsing stores
20 ; RUN: llvm-dis %t3.2.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN-SRC
22 ; IMPORT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4
23 ; IMPORT-NEXT: @gBar = internal local_unnamed_addr global i32 2, align 4
24 ; IMPORT: !DICompileUnit({{.*}})
29 ; CODEGEN-NEXT: %1 = tail call i32 @rand()
30 ; CODEGEN-NEXT: %2 = tail call i32 @rand()
31 ; CODEGEN-NEXT: ret i32 0
33 ; CODEGEN-SRC-NOT: gFoo
34 ; CODEGEN-SRC-NOT: gBar
35 ; CODEGEN-SRC: void @baz()
36 ; CODEGEN-SRC-NEXT: %1 = tail call i32 @rand()
37 ; CODEGEN-SRC-NEXT: %2 = tail call i32 @rand()
38 ; CODEGEN-SRC-NEXT: ret void
40 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41 target triple = "x86_64-pc-linux-gnu"
43 ; We should be able to link external definition of gBar to its declaration
44 @gBar = external global i32
46 define i32 @main() local_unnamed_addr {
50 declare void @baz() local_unnamed_addr