[C++20][Modules][Serialization] Add an additional test case for #120277. (#126349)
[llvm-project.git] / llvm / test / CodeGen / AArch64 / cgdata-merge-gvar-string.ll
blob1e67425f0b84759c72281c7dbe6e08990127f897
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.
5 ; RUN: llc -mtriple=arm64-apple-darwin -enable-global-merge-func=true -global-merging-skip-no-params=false < %s | FileCheck %s
7 ; CHECK: _f1.Tgm
8 ; CHECK: _f2.Tgm
9 ; CHECK-NOT: _f3.Tgm
10 ; CHECK-NOT: _f4.Tgm
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 1
14 @.str.1 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
15 @.str.2 = private unnamed_addr constant [6 x i8] c"diff2\00", align 1
16 @.str.3 = private unnamed_addr constant [6 x i8] c"diff3\00", align 1
18 declare i32 @goo(ptr noundef)
20 define i32 @f1() {
21 entry:
22   %call = tail call i32 @goo(ptr noundef nonnull @.str)
23   %add = add nsw i32 %call, 1
24   ret i32 %add
27 define i32 @f2() {
28 entry:
29   %call = tail call i32 @goo(ptr noundef nonnull @.str.1)
30   %add = add nsw i32 %call, 1
31   ret i32 %add
34 define i32 @f3() {
35 entry:
36   %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.2)
37   %add = sub nsw i32 %call, 1
38   ret i32 %add
41 define i32 @f4() {
42 entry:
43   %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.3)
44   %add = sub nsw i32 %call, 1
45   ret i32 %add