brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 7f02037 Raw
106 lines · plain
1; Check constant propagation in thinlto combined summary. This allows us to do 2 things:2;  1. Internalize global definition which is not used externally if all accesses to it are read-only3;  2. Make a local copy of internal definition if all accesses to it are readonly. This allows constant4;     folding it during optimziation phase.5; RUN: opt -module-summary %s -o %t1.bc6; RUN: opt -module-summary %p/Inputs/index-const-prop.ll -o %t2.bc7; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \8; RUN:  -r=%t2.bc,foo,pl \9; RUN:  -r=%t2.bc,bar,pl \10; RUN:  -r=%t2.bc,baz,pl \11; RUN:  -r=%t2.bc,rand, \12; RUN:  -r=%t2.bc,gBar,pl \13; RUN:  -r=%t1.bc,main,plx \14; RUN:  -r=%t1.bc,main2,pl \15; RUN:  -r=%t1.bc,foo, \16; RUN:  -r=%t1.bc,bar, \17; RUN:  -r=%t1.bc,baz, \18; RUN:  -r=%t1.bc,gBar, \19; RUN:  -o %t320; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT21; RUN: llvm-dis %t3.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN22 23; Now check that we won't internalize global (gBar) if it's externally referenced24; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \25; RUN:  -r=%t2.bc,foo,pl \26; RUN:  -r=%t2.bc,bar,pl \27; RUN:  -r=%t2.bc,baz,pl \28; RUN:  -r=%t2.bc,rand, \29; RUN:  -r=%t2.bc,gBar,plx \30; RUN:  -r=%t1.bc,main,plx \31; RUN:  -r=%t1.bc,main2,pl \32; RUN:  -r=%t1.bc,foo, \33; RUN:  -r=%t1.bc,bar, \34; RUN:  -r=%t1.bc,baz, \35; RUN:  -r=%t1.bc,gBar, \36; RUN:  -o %t437; RUN: llvm-dis %t4.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT238 39; Run again but with main2 exported instead of main to check that write only40; variables are optimized out.41; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \42; RUN:  -r=%t2.bc,foo,pl \43; RUN:  -r=%t2.bc,bar,pl \44; RUN:  -r=%t2.bc,baz,pl \45; RUN:  -r=%t2.bc,rand, \46; RUN:  -r=%t2.bc,gBar,pl \47; RUN:  -r=%t1.bc,main,pl \48; RUN:  -r=%t1.bc,main2,plx \49; RUN:  -r=%t1.bc,foo, \50; RUN:  -r=%t1.bc,bar, \51; RUN:  -r=%t1.bc,baz, \52; RUN:  -r=%t1.bc,gBar, \53; RUN:  -o %t554; RUN: llvm-dis %t5.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT-WRITEONLY55; RUN: llvm-dis %t5.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN256; Check that gFoo and gBar were eliminated from source module together57; with corresponsing stores58; RUN: llvm-dis %t5.2.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN2-SRC59 60; IMPORT:       @gBar = internal local_unnamed_addr global i32 2, align 461; IMPORT-NEXT:  @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 462; IMPORT:       !DICompileUnit({{.*}})63 64; Write only variables are imported with a zero initializer.65; IMPORT-WRITEONLY:  @gBar = internal local_unnamed_addr global i32 066; IMPORT-WRITEONLY:  @gFoo.llvm.0 = internal unnamed_addr global i32 067 68; CODEGEN:        i32 @main()69; CODEGEN-NEXT:     ret i32 370 71; IMPORT2: @gBar = available_externally local_unnamed_addr global i32 2, align 472 73; CODEGEN2:      i32 @main274; CODEGEN2-NEXT:   %1 = tail call i32 @rand()75; CODEGEN2-NEXT:   %2 = tail call i32 @rand()76; CODEGEN2-NEXT:   ret i32 077 78; CODEGEN2-SRC:       void @baz()79; CODEGEN2-SRC-NEXT:    %1 = tail call i32 @rand()80; CODEGEN2-SRC-NEXT:    %2 = tail call i32 @rand()81; CODEGEN2-SRC-NEXT:    ret void82 83target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"84target triple = "x86_64-pc-linux-gnu"85 86; We should be able to link external definition of gBar to its declaration87@gBar = external global i3288 89define i32 @main() local_unnamed_addr {90  %call = tail call i32 @foo()91  %call1 = tail call i32 @bar()92  %add = add nsw i32 %call1, %call93  ret i32 %add94}95 96define i32 @main2() local_unnamed_addr {97  tail call void @baz()98  ret i32 099}100 101declare i32 @foo(...) local_unnamed_addr102 103declare i32 @bar(...) local_unnamed_addr104 105declare void @baz() local_unnamed_addr106