brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · f1a5d1a Raw
97 lines · plain
1; This test is similar to cgdata-read-double-outline.ll, but it is executed with LTO (Link Time Optimization).2; It demonstrates how identical instruction sequences are handled during global outlining.3; Currently, we do not attempt to reuse an outlined function for identical sequences.4; Instead, each instruction sequence that appears in the global outlined hash tree5; is outlined into its own unique function.6 7; RUN: split-file %s %t8 9; We first create the cgdata file from a local outline instance in local-two.ll10; RUN: opt -module-summary %t/local-two.ll -o %t/write.bc11; RUN: llvm-lto2 run %t/write.bc -o %t/write \12; RUN:  -r %t/write.bc,_f1,px -r %t/write.bc,_f2,px -r %t/write.bc,_g,p \13; RUN:  -codegen-data-generate=true14; RUN: llvm-cgdata --merge %t/write.1 -o %t_cgdata15; RUN: llvm-cgdata --show %t_cgdata | FileCheck %s --check-prefix=SHOW16 17; SHOW: Outlined hash tree:18; SHOW-NEXT:  Total Node Count: 419; SHOW-NEXT:  Terminal Node Count: 120; SHOW-NEXT:  Depth: 321 22; Now, we execute either ThinLTO or LTO by reading the cgdata for local-two-another.ll.23; With ThinLTO, similar to the no-LTO scenario shown in cgdata-read-double-outline.ll,24; it optimistically outlines each instruction sequence that matches against25; the global outlined hash tree. Since each matching sequence is considered a candidate,26; we expect to generate two unique outlined functions that will be folded27; by the linker at a later stage.28; However, with LTO, we do not utilize the cgdata, but instead fall back to the default29; outliner mode. This results in a single outlined function that is30; shared across two call-sites.31 32; Run ThinLTO33; RUN: opt -module-summary %t/local-two-another.ll -o %t/thinlto.bc34; RUN: llvm-lto2 run %t/thinlto.bc -o %t/thinlto \35; RUN:  -r %t/thinlto.bc,_f3,px -r %t/thinlto.bc,_f4,px -r %t/thinlto.bc,_g,p \36; RUN:  -codegen-data-use-path=%t_cgdata37; RUN: llvm-objdump -d %t/thinlto.1 | FileCheck %s38 39; CHECK: _OUTLINED_FUNCTION_{{.*}}:40; CHECK-NEXT:  mov41; CHECK-NEXT:  mov42; CHECK-NEXT:  b43; CHECK: _OUTLINED_FUNCTION_{{.*}}:44; CHECK-NEXT:  mov45; CHECK-NEXT:  mov46; CHECK-NEXT:  b47 48; Run ThinLTO while disabling the global outliner.49; We have a single outlined case with the default outliner.50; RUN: llvm-lto2 run %t/thinlto.bc -o %t/thinlto-disable \51; RUN:  -r %t/thinlto.bc,_f3,px -r %t/thinlto.bc,_f4,px -r %t/thinlto.bc,_g,p \52; RUN:  -enable-machine-outliner \53; RUN:  -codegen-data-use-path=%t_cgdata \54; RUN:  -disable-global-outlining55; RUN: llvm-objdump -d %t/thinlto-disable.1 | FileCheck %s --check-prefix=DISABLE56 57; DISABLE: _OUTLINED_FUNCTION_{{.*}}:58; DISABLE-NEXT:  mov59; DISABLE-NEXT:  mov60; DISABLE-NEXT:  b61; DISABLE-NOT: _OUTLINED_FUNCTION_{{.*}}:62 63; Run LTO, which effectively disables the global outliner.64; RUN: opt %t/local-two-another.ll -o %t/lto.bc65; RUN: llvm-lto2 run %t/lto.bc -o %t/lto \66; RUN:  -r %t/lto.bc,_f3,px -r %t/lto.bc,_f4,px -r %t/lto.bc,_g,p \67; RUN:  -enable-machine-outliner \68; RUN:  -codegen-data-use-path=%t_cgdata69; RUN: llvm-objdump -d %t/lto.0 | FileCheck %s --check-prefix=DISABLE70 71;--- local-two.ll72target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"73target triple = "arm64-apple-darwin"74declare i32 @g(i32, i32, i32)75define i32 @f1() minsize {76  %1 = call i32 @g(i32 10, i32 1, i32 2);77  ret i32 %178}79define i32 @f2() minsize {80  %1 = call i32 @g(i32 20, i32 1, i32 2);81  ret i32 %182}83 84;--- local-two-another.ll85target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"86target triple = "arm64-apple-darwin"87 88declare i32 @g(i32, i32, i32)89define i32 @f3() minsize {90  %1 = call i32 @g(i32 30, i32 1, i32 2);91  ret i32 %192}93define i32 @f4() minsize {94  %1 = call i32 @g(i32 40, i32 1, i32 2);95  ret i32 %196}97