brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 9eb9bda Raw
97 lines · plain
1; This test demonstrates how similar functions are handled during global outlining.2; Currently, we do not attempt to share an merged function for identical sequences.3; Instead, each merging instance is created uniquely.4 5; RUN: rm -rf %t; split-file %s %t6 7; RUN: opt -module-summary -module-hash %t/foo.ll -o %t-foo.bc8; RUN: opt -module-summary -module-hash %t/goo.ll -o %t-goo.bc9 10; First, run with -codegen-data-generate=true to generate the cgdata in the object files.11; Using llvm-cgdata, merge the cg data.12; RUN: llvm-lto2 run -enable-global-merge-func=true -codegen-data-generate=true %t-foo.bc %t-goo.bc -o %tout-write \13; RUN:    -r %t-foo.bc,_f1,px \14; RUN:    -r %t-goo.bc,_f2,px \15; RUN:    -r %t-foo.bc,_g,l -r %t-foo.bc,_g1,l -r %t-foo.bc,_g2,l \16; RUN:    -r %t-goo.bc,_g,l -r %t-goo.bc,_g1,l -r %t-goo.bc,_g2,l17; RUN: llvm-cgdata --merge -o %tout.cgdata %tout-write.1 %tout-write.218 19; Now run with -codegen-data-use-path=%tout.cgdata to optimize the binary.20; Each module has its own merging instance as it is matched against the merged cgdata.21; RUN: llvm-lto2 run -enable-global-merge-func=true \22; RUN:    -codegen-data-use-path=%tout.cgdata \23; RUN:    %t-foo.bc %t-goo.bc -o %tout-read \24; RUN:    -r %t-foo.bc,_f1,px \25; RUN:    -r %t-goo.bc,_f2,px \26; RUN:    -r %t-foo.bc,_g,l -r %t-foo.bc,_g1,l -r %t-foo.bc,_g2,l \27; RUN:    -r %t-goo.bc,_g,l -r %t-goo.bc,_g1,l -r %t-goo.bc,_g2,l28; RUN: llvm-nm %tout-read.1 | FileCheck %s --check-prefix=READ129; RUN: llvm-nm %tout-read.2 | FileCheck %s --check-prefix=READ230; RUN: llvm-objdump -d %tout-read.1 | FileCheck %s --check-prefix=THUNK131; RUN: llvm-objdump -d %tout-read.2 | FileCheck %s --check-prefix=THUNK232 33; It runs the same if we use -indexed-codegen-data-read-function-map-names=false.34; RUN: llvm-lto2 run -enable-global-merge-func=true \35; RUN:    -indexed-codegen-data-read-function-map-names=false \36; RUN:    -codegen-data-use-path=%tout.cgdata \37; RUN:    %t-foo.bc %t-goo.bc -o %tout-read \38; RUN:    -r %t-foo.bc,_f1,px \39; RUN:    -r %t-goo.bc,_f2,px \40; RUN:    -r %t-foo.bc,_g,l -r %t-foo.bc,_g1,l -r %t-foo.bc,_g2,l \41; RUN:    -r %t-goo.bc,_g,l -r %t-goo.bc,_g1,l -r %t-goo.bc,_g2,l42; RUN: llvm-nm %tout-read.1 | FileCheck %s --check-prefix=READ143; RUN: llvm-nm %tout-read.2 | FileCheck %s --check-prefix=READ244; RUN: llvm-objdump -d %tout-read.1 | FileCheck %s --check-prefix=THUNK145; RUN: llvm-objdump -d %tout-read.2 | FileCheck %s --check-prefix=THUNK246 47; READ1: _f1.Tgm48; READ2: _f2.Tgm49 50; THUNK1: <_f1>:51; THUNK1-NEXT: adrp x1,52; THUNK1-NEXT: ldr x1, [x1]53; THUNK1-NEXT: b54 55; THUNK2: <_f2>:56; THUNK2-NEXT: adrp x1,57; THUNK2-NEXT: ldr x1, [x1]58; THUNK2-NEXT: b59 60;--- foo.ll61target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"62target triple = "arm64-unknown-ios12.0.0"63 64@g = external local_unnamed_addr global [0 x i32], align 465@g1 = external global i32, align 466@g2 = external global i32, align 467 68define i32 @f1(i32 %a) {69entry:70  %idxprom = sext i32 %a to i6471  %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom72  %0 = load i32, i32* %arrayidx, align 473  %1 = load volatile i32, i32* @g1, align 474  %mul = mul nsw i32 %1, %075  %add = add nsw i32 %mul, 176  ret i32 %add77}78 79;--- goo.ll80target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"81target triple = "arm64-unknown-ios12.0.0"82 83@g = external local_unnamed_addr global [0 x i32], align 484@g1 = external global i32, align 485@g2 = external global i32, align 486 87define i32 @f2(i32 %a) {88entry:89  %idxprom = sext i32 %a to i6490  %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i64 0, i64 %idxprom91  %0 = load i32, i32* %arrayidx, align 492  %1 = load volatile i32, i32* @g2, align 493  %mul = mul nsw i32 %1, %094  %add = add nsw i32 %mul, 195  ret i32 %add96}97