xref: /llvm-project/llvm/test/CodeGen/X86/GlobalISel/GV.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-linux-gnu    -global-isel -verify-machineinstrs                       < %s -o - | FileCheck %s --check-prefix=X64
3; RUN: llc -mtriple=x86_64-apple-darwin -global-isel -verify-machineinstrs -relocation-model=pic < %s -o - | FileCheck %s --check-prefix=X64_DARWIN_PIC
4; RUN: llc -mtriple=i386-linux-gnu      -global-isel -verify-machineinstrs                       < %s -o - | FileCheck %s --check-prefix=X32
5; RUN: llc -mtriple=x86_64-linux-gnux32 -global-isel -verify-machineinstrs                       < %s -o - | FileCheck %s --check-prefix=X32ABI
6
7@g_int = dso_local global i32 0, align 4
8
9; Function Attrs: noinline nounwind optnone uwtable
10define dso_local ptr @test_global_ptrv() #3 {
11; X64-LABEL: test_global_ptrv:
12; X64:       # %bb.0: # %entry
13; X64-NEXT:    leaq g_int, %rax
14; X64-NEXT:    retq
15;
16; X64_DARWIN_PIC-LABEL: test_global_ptrv:
17; X64_DARWIN_PIC:       ## %bb.0: ## %entry
18; X64_DARWIN_PIC-NEXT:    leaq _g_int(%rip), %rax
19; X64_DARWIN_PIC-NEXT:    retq
20;
21; X32-LABEL: test_global_ptrv:
22; X32:       # %bb.0: # %entry
23; X32-NEXT:    leal g_int, %eax
24; X32-NEXT:    retl
25;
26; X32ABI-LABEL: test_global_ptrv:
27; X32ABI:       # %bb.0: # %entry
28; X32ABI-NEXT:    leal g_int, %eax
29; X32ABI-NEXT:    movl %eax, %eax
30; X32ABI-NEXT:    retq
31entry:
32  ret ptr @g_int
33}
34
35; Function Attrs: noinline nounwind optnone uwtable
36define dso_local i32 @test_global_valv() #3 {
37; X64-LABEL: test_global_valv:
38; X64:       # %bb.0: # %entry
39; X64-NEXT:    leaq g_int, %rax
40; X64-NEXT:    movl (%rax), %eax
41; X64-NEXT:    retq
42;
43; X64_DARWIN_PIC-LABEL: test_global_valv:
44; X64_DARWIN_PIC:       ## %bb.0: ## %entry
45; X64_DARWIN_PIC-NEXT:    leaq _g_int(%rip), %rax
46; X64_DARWIN_PIC-NEXT:    movl (%rax), %eax
47; X64_DARWIN_PIC-NEXT:    retq
48;
49; X32-LABEL: test_global_valv:
50; X32:       # %bb.0: # %entry
51; X32-NEXT:    leal g_int, %eax
52; X32-NEXT:    movl (%eax), %eax
53; X32-NEXT:    retl
54;
55; X32ABI-LABEL: test_global_valv:
56; X32ABI:       # %bb.0: # %entry
57; X32ABI-NEXT:    leal g_int, %eax
58; X32ABI-NEXT:    movl (%eax), %eax
59; X32ABI-NEXT:    retq
60entry:
61  %0 = load i32, ptr @g_int, align 4
62  ret i32 %0
63}
64
65