brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 1e67425 Raw
47 lines · plain
1; This test verifies that global variables (string) are hashed based on their initial contents,2; allowing them to be merged even if they appear different due to their names.3; Now they become identical functions that can be merged without creating a parameter.4 5; RUN: llc -mtriple=arm64-apple-darwin -enable-global-merge-func=true -global-merging-skip-no-params=false < %s | FileCheck %s6 7; CHECK: _f1.Tgm8; CHECK: _f2.Tgm9; CHECK-NOT: _f3.Tgm10; CHECK-NOT: _f4.Tgm11 12; The initial contents of `.str` and `.str.1` are identical, but not with those of `.str.2` and `.str.3`.13@.str = private unnamed_addr constant [6 x i8] c"hello\00", align 114@.str.1 = private unnamed_addr constant [6 x i8] c"hello\00", align 115@.str.2 = private unnamed_addr constant [6 x i8] c"diff2\00", align 116@.str.3 = private unnamed_addr constant [6 x i8] c"diff3\00", align 117 18declare i32 @goo(ptr noundef)19 20define i32 @f1() {21entry:22  %call = tail call i32 @goo(ptr noundef nonnull @.str)23  %add = add nsw i32 %call, 124  ret i32 %add25}26 27define i32 @f2() {28entry:29  %call = tail call i32 @goo(ptr noundef nonnull @.str.1)30  %add = add nsw i32 %call, 131  ret i32 %add32}33 34define i32 @f3() {35entry:36  %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.2)37  %add = sub nsw i32 %call, 138  ret i32 %add39}40 41define i32 @f4() {42entry:43  %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.3)44  %add = sub nsw i32 %call, 145  ret i32 %add46}47