• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
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.
7
8; RUN: llc < %s -relocation-model=pic    -code-model=small  | FileCheck %s --check-prefix=SMALL-PIC
9; RUN: llc < %s -relocation-model=pic    -code-model=medium | FileCheck %s --check-prefix=MEDIUM-PIC
10; RUN: llc < %s -relocation-model=pic    -code-model=large  | FileCheck %s --check-prefix=LARGE-PIC
11
12; Generated from this C source:
13;
14; int main() {
15;   unsigned int a[100] = {0};
16;   return 0;
17; }
18
19; ModuleID = 'model.c'
20source_filename = "model.c"
21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22target triple = "x86_64--linux"
23
24declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #1
25
26define 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
40;
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
54;
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
73entry:
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)
79  ret i32 0
80}
81
82attributes #0 = { noinline nounwind uwtable }
83attributes #0 = { argmemonly nounwind uwtable }
84
85!llvm.module.flags = !{!0, !1, !2}
86!llvm.ident = !{!3}
87
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 "}
92