1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Run with --no_x86_scrub_rip because we care a lot about how globals are
3 ; accessed in the code model.
5 ; Memset is interesting because it is an ExternalSymbol reference instead of a
6 ; GlobalValue. Make sure we do the right GOT load for 64-bit large.
8 ; RUN: llc < %s -relocation-model=pic -code-model=small | FileCheck %s --check-prefix=CHECK --check-prefix=SMALL-PIC
9 ; RUN: llc < %s -relocation-model=pic -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-PIC
10 ; RUN: llc < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC
12 ; Generated from this C source:
15 ; unsigned int a[100] = {0};
19 ; ModuleID = 'model.c'
20 source_filename = "model.c"
21 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64--linux"
24 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #1
26 define i32 @main() #0 {
27 ; SMALL-PIC-LABEL: main:
28 ; SMALL-PIC: # %bb.0: # %entry
29 ; SMALL-PIC-NEXT: subq $424, %rsp # imm = 0x1A8
30 ; SMALL-PIC-NEXT: .cfi_def_cfa_offset 432
31 ; SMALL-PIC-NEXT: movl $0, {{[0-9]+}}(%rsp)
32 ; SMALL-PIC-NEXT: leaq {{[0-9]+}}(%rsp), %rdi
33 ; SMALL-PIC-NEXT: movl $400, %edx # imm = 0x190
34 ; SMALL-PIC-NEXT: xorl %esi, %esi
35 ; SMALL-PIC-NEXT: callq memset@PLT
36 ; SMALL-PIC-NEXT: xorl %eax, %eax
37 ; SMALL-PIC-NEXT: addq $424, %rsp # imm = 0x1A8
38 ; SMALL-PIC-NEXT: .cfi_def_cfa_offset 8
39 ; SMALL-PIC-NEXT: retq
41 ; MEDIUM-PIC-LABEL: main:
42 ; MEDIUM-PIC: # %bb.0: # %entry
43 ; MEDIUM-PIC-NEXT: subq $424, %rsp # imm = 0x1A8
44 ; MEDIUM-PIC-NEXT: .cfi_def_cfa_offset 432
45 ; MEDIUM-PIC-NEXT: movl $0, {{[0-9]+}}(%rsp)
46 ; MEDIUM-PIC-NEXT: leaq {{[0-9]+}}(%rsp), %rdi
47 ; MEDIUM-PIC-NEXT: movl $400, %edx # imm = 0x190
48 ; MEDIUM-PIC-NEXT: xorl %esi, %esi
49 ; MEDIUM-PIC-NEXT: callq memset@PLT
50 ; MEDIUM-PIC-NEXT: xorl %eax, %eax
51 ; MEDIUM-PIC-NEXT: addq $424, %rsp # imm = 0x1A8
52 ; MEDIUM-PIC-NEXT: .cfi_def_cfa_offset 8
53 ; MEDIUM-PIC-NEXT: retq
55 ; LARGE-PIC-LABEL: main:
56 ; LARGE-PIC: # %bb.0: # %entry
57 ; LARGE-PIC-NEXT: subq $424, %rsp # imm = 0x1A8
58 ; LARGE-PIC-NEXT: .cfi_def_cfa_offset 432
59 ; LARGE-PIC-NEXT: .L0$pb:
60 ; LARGE-PIC-NEXT: leaq .L0${{.*}}(%rip), %rax
61 ; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx
62 ; LARGE-PIC-NEXT: addq %rax, %rcx
63 ; LARGE-PIC-NEXT: movl $0, {{[0-9]+}}(%rsp)
64 ; LARGE-PIC-NEXT: leaq {{[0-9]+}}(%rsp), %rdi
65 ; LARGE-PIC-NEXT: movabsq $memset@GOT, %rax
66 ; LARGE-PIC-NEXT: movl $400, %edx # imm = 0x190
67 ; LARGE-PIC-NEXT: xorl %esi, %esi
68 ; LARGE-PIC-NEXT: callq *(%rcx,%rax)
69 ; LARGE-PIC-NEXT: xorl %eax, %eax
70 ; LARGE-PIC-NEXT: addq $424, %rsp # imm = 0x1A8
71 ; LARGE-PIC-NEXT: .cfi_def_cfa_offset 8
72 ; LARGE-PIC-NEXT: retq
74 %retval = alloca i32, align 4
75 %a = alloca [100 x i32], align 16
76 store i32 0, i32* %retval, align 4
77 %0 = bitcast [100 x i32]* %a to i8*
78 call void @llvm.memset.p0i8.i64(i8* align 16 %0, i8 0, i64 400, i1 false)
82 attributes #0 = { noinline nounwind uwtable }
83 attributes #0 = { argmemonly nounwind uwtable }
85 !llvm.module.flags = !{!0, !1, !2}
88 !0 = !{i32 1, !"wchar_size", i32 4}
89 !1 = !{i32 7, !"PIC Level", i32 2}
90 !2 = !{i32 7, !"PIE Level", i32 2}
91 !3 = !{!"clang version 7.0.0 "}