65 lines · plain
1; This test verifies that global variables are hashed based on their initial contents,2; allowing them to be outlined even if they appear different due to their names.3 4; RUN: split-file %s %t5 6; The outlined function is created locally.7; Note that `.str.3` is commonly used in both `f1()` and `f2()`.8; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-generate -aarch64-enable-collect-loh=false \9; RUN: %t/local-two.ll -o - | FileCheck %s --check-prefix=WRITE10 11; WRITE-LABEL: _OUTLINED_FUNCTION_{{.*}}:12; WRITE: adrp x1, l_.str.313; WRITE-NEXT: add x1, x1, l_.str.314; WRITE-NEXT: mov w215; WRITE-NEXT: mov w316; WRITE-NEXT: mov w417; WRITE-NEXT: b18 19; Create an object file and merge it into the cgdata.20; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-generate -aarch64-enable-collect-loh=false \21; RUN: -filetype=obj %t/local-two.ll -o %t_write_base22; RUN: llvm-cgdata --merge %t_write_base -o %t_cgdata_base23 24; Read the cgdata in the machine outliner for optimistically outlining in local-one.ll.25; Note that the hash of `.str.5` in local-one.ll matches that of `.str.3` in an outlined tree in the cgdata.26 27; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-use-path=%t_cgdata_base -aarch64-enable-collect-loh=false \28; RUN: %t/local-one.ll -o - | FileCheck %s --check-prefix=READ29 30; READ-LABEL: _OUTLINED_FUNCTION_{{.*}}:31; READ: adrp x1, l_.str.532; READ-NEXT: add x1, x1, l_.str.533; READ-NEXT: mov w234; READ-NEXT: mov w335; READ-NEXT: mov w436; READ-NEXT: b37 38;--- local-two.ll39@.str.1 = private unnamed_addr constant [3 x i8] c"f1\00", align 140@.str.2 = private unnamed_addr constant [3 x i8] c"f2\00", align 141@.str.3 = private unnamed_addr constant [6 x i8] c"hello\00", align 142 43declare noundef i32 @goo(ptr noundef, ptr noundef, i32, i32, i32)44define i32 @f1() minsize {45entry:46 %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3, i32 1, i32 2, i32 3)47 ret i32 %call48}49define i32 @f2() minsize {50entry:51 %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 1, i32 2, i32 3)52 ret i32 %call53}54 55;--- local-one.ll56@.str.4 = private unnamed_addr constant [3 x i8] c"f3\00", align 157@.str.5 = private unnamed_addr constant [6 x i8] c"hello\00", align 158 59declare noundef i32 @goo(ptr noundef, ptr noundef, i32, i32, i32)60define i32 @f1() minsize {61entry:62 %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, i32 1, i32 2, i32 3)63 ret i32 %call64}65