11
11
; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC
12
12
; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large -large-data-threshold=1000 | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-SMALL-DATA-PIC
13
13
14
+ ; Check that the relocations we emit are valid.
15
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=small -filetype=obj -o /dev/null
16
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=medium -filetype=obj -o /dev/null
17
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=large -filetype=obj -o /dev/null
18
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=small -filetype=obj -o /dev/null
19
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium -large-data-threshold=1000 -filetype=obj -o /dev/null
20
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium -filetype=obj -o /dev/null
21
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large -filetype=obj -o /dev/null
22
+ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large -large-data-threshold=1000 -filetype=obj -o /dev/null
23
+
14
24
; Generated from this C source:
15
25
;
16
26
; static int static_data[10];
@@ -376,7 +386,6 @@ define dso_local ptr @lea_forced_small_data() #0 {
376
386
ret ptr @forced_small_data
377
387
}
378
388
379
- ; TODO: make small and medium instruction sequence the same
380
389
define dso_local i32 @load_forced_small_data () #0 {
381
390
; SMALL-STATIC-LABEL: load_forced_small_data:
382
391
; SMALL-STATIC: # %bb.0:
@@ -385,14 +394,13 @@ define dso_local i32 @load_forced_small_data() #0 {
385
394
;
386
395
; MEDIUM-STATIC-LABEL: load_forced_small_data:
387
396
; MEDIUM-STATIC: # %bb.0:
388
- ; MEDIUM-STATIC-NEXT: movl $forced_small_data, %eax
389
- ; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax
397
+ ; MEDIUM-STATIC-NEXT: movl forced_small_data+8(%rip), %eax
390
398
; MEDIUM-STATIC-NEXT: retq
391
399
;
392
400
; LARGE-STATIC-LABEL: load_forced_small_data:
393
401
; LARGE-STATIC: # %bb.0:
394
- ; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
395
- ; LARGE-STATIC-NEXT: movl 8 (%rax), %eax
402
+ ; LARGE-STATIC-NEXT: movl $forced_small_data+8 , %eax
403
+ ; LARGE-STATIC-NEXT: movl (%rax), %eax
396
404
; LARGE-STATIC-NEXT: retq
397
405
;
398
406
; SMALL-PIC-LABEL: load_forced_small_data:
@@ -402,14 +410,12 @@ define dso_local i32 @load_forced_small_data() #0 {
402
410
;
403
411
; MEDIUM-SMALL-DATA-PIC-LABEL: load_forced_small_data:
404
412
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
405
- ; MEDIUM-SMALL-DATA-PIC-NEXT: leaq forced_small_data(%rip), %rax
406
- ; MEDIUM-SMALL-DATA-PIC-NEXT: movl 8(%rax), %eax
413
+ ; MEDIUM-SMALL-DATA-PIC-NEXT: movl forced_small_data+8(%rip), %eax
407
414
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
408
415
;
409
416
; MEDIUM-PIC-LABEL: load_forced_small_data:
410
417
; MEDIUM-PIC: # %bb.0:
411
- ; MEDIUM-PIC-NEXT: leaq forced_small_data(%rip), %rax
412
- ; MEDIUM-PIC-NEXT: movl 8(%rax), %eax
418
+ ; MEDIUM-PIC-NEXT: movl forced_small_data+8(%rip), %eax
413
419
; MEDIUM-PIC-NEXT: retq
414
420
;
415
421
; LARGE-PIC-LABEL: load_forced_small_data:
@@ -435,7 +441,6 @@ define dso_local i32 @load_forced_small_data() #0 {
435
441
ret i32 %rv
436
442
}
437
443
438
- ; TODO: fix small code model instruction sequences to use 64-bit constants
439
444
define dso_local ptr @lea_forced_large_data () #0 {
440
445
; SMALL-STATIC-LABEL: lea_forced_large_data:
441
446
; SMALL-STATIC: # %bb.0:
@@ -454,8 +459,9 @@ define dso_local ptr @lea_forced_large_data() #0 {
454
459
;
455
460
; SMALL-PIC-LABEL: lea_forced_large_data:
456
461
; SMALL-PIC: # %bb.0:
457
- ; SMALL-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
458
- ; SMALL-PIC-NEXT: leaq forced_large_data@GOTOFF(%rax), %rax
462
+ ; SMALL-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
463
+ ; SMALL-PIC-NEXT: movabsq $forced_large_data@GOTOFF, %rax
464
+ ; SMALL-PIC-NEXT: addq %rcx, %rax
459
465
; SMALL-PIC-NEXT: retq
460
466
;
461
467
; MEDIUM-SMALL-DATA-PIC-LABEL: lea_forced_large_data:
@@ -497,25 +503,27 @@ define dso_local ptr @lea_forced_large_data() #0 {
497
503
define dso_local i32 @load_forced_large_data () #0 {
498
504
; SMALL-STATIC-LABEL: load_forced_large_data:
499
505
; SMALL-STATIC: # %bb.0:
500
- ; SMALL-STATIC-NEXT: movl forced_large_data+8(%rip), %eax
506
+ ; SMALL-STATIC-NEXT: movabsq $forced_large_data+8, %rax
507
+ ; SMALL-STATIC-NEXT: movl (%rax), %eax
501
508
; SMALL-STATIC-NEXT: retq
502
509
;
503
510
; MEDIUM-STATIC-LABEL: load_forced_large_data:
504
511
; MEDIUM-STATIC: # %bb.0:
505
- ; MEDIUM-STATIC-NEXT: movabsq $forced_large_data, %rax
506
- ; MEDIUM-STATIC-NEXT: movl 8 (%rax), %eax
512
+ ; MEDIUM-STATIC-NEXT: movabsq $forced_large_data+8 , %rax
513
+ ; MEDIUM-STATIC-NEXT: movl (%rax), %eax
507
514
; MEDIUM-STATIC-NEXT: retq
508
515
;
509
516
; LARGE-STATIC-LABEL: load_forced_large_data:
510
517
; LARGE-STATIC: # %bb.0:
511
- ; LARGE-STATIC-NEXT: movabsq $forced_large_data, %rax
512
- ; LARGE-STATIC-NEXT: movl 8 (%rax), %eax
518
+ ; LARGE-STATIC-NEXT: movabsq $forced_large_data+8 , %rax
519
+ ; LARGE-STATIC-NEXT: movl (%rax), %eax
513
520
; LARGE-STATIC-NEXT: retq
514
521
;
515
522
; SMALL-PIC-LABEL: load_forced_large_data:
516
523
; SMALL-PIC: # %bb.0:
517
524
; SMALL-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
518
- ; SMALL-PIC-NEXT: movl forced_large_data@GOTOFF+8(%rax), %eax
525
+ ; SMALL-PIC-NEXT: movabsq $forced_large_data@GOTOFF, %rcx
526
+ ; SMALL-PIC-NEXT: movl 8(%rax,%rcx), %eax
519
527
; SMALL-PIC-NEXT: retq
520
528
;
521
529
; MEDIUM-SMALL-DATA-PIC-LABEL: load_forced_large_data:
@@ -563,14 +571,14 @@ define dso_local i32 @load_global_data() #0 {
563
571
;
564
572
; MEDIUM-STATIC-LABEL: load_global_data:
565
573
; MEDIUM-STATIC: # %bb.0:
566
- ; MEDIUM-STATIC-NEXT: movabsq $global_data, %rax
567
- ; MEDIUM-STATIC-NEXT: movl 8 (%rax), %eax
574
+ ; MEDIUM-STATIC-NEXT: movabsq $global_data+8 , %rax
575
+ ; MEDIUM-STATIC-NEXT: movl (%rax), %eax
568
576
; MEDIUM-STATIC-NEXT: retq
569
577
;
570
578
; LARGE-STATIC-LABEL: load_global_data:
571
579
; LARGE-STATIC: # %bb.0:
572
- ; LARGE-STATIC-NEXT: movabsq $global_data, %rax
573
- ; LARGE-STATIC-NEXT: movl 8 (%rax), %eax
580
+ ; LARGE-STATIC-NEXT: movabsq $global_data+8 , %rax
581
+ ; LARGE-STATIC-NEXT: movl (%rax), %eax
574
582
; LARGE-STATIC-NEXT: retq
575
583
;
576
584
; SMALL-PIC-LABEL: load_global_data:
@@ -580,8 +588,7 @@ define dso_local i32 @load_global_data() #0 {
580
588
;
581
589
; MEDIUM-SMALL-DATA-PIC-LABEL: load_global_data:
582
590
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
583
- ; MEDIUM-SMALL-DATA-PIC-NEXT: leaq global_data(%rip), %rax
584
- ; MEDIUM-SMALL-DATA-PIC-NEXT: movl 8(%rax), %eax
591
+ ; MEDIUM-SMALL-DATA-PIC-NEXT: movl global_data+8(%rip), %eax
585
592
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
586
593
;
587
594
; MEDIUM-PIC-LABEL: load_global_data:
@@ -684,14 +691,14 @@ define dso_local i32 @load_unknown_size_data() #0 {
684
691
;
685
692
; MEDIUM-STATIC-LABEL: load_unknown_size_data:
686
693
; MEDIUM-STATIC: # %bb.0:
687
- ; MEDIUM-STATIC-NEXT: movabsq $unknown_size_data, %rax
688
- ; MEDIUM-STATIC-NEXT: movl 8 (%rax), %eax
694
+ ; MEDIUM-STATIC-NEXT: movabsq $unknown_size_data+8 , %rax
695
+ ; MEDIUM-STATIC-NEXT: movl (%rax), %eax
689
696
; MEDIUM-STATIC-NEXT: retq
690
697
;
691
698
; LARGE-STATIC-LABEL: load_unknown_size_data:
692
699
; LARGE-STATIC: # %bb.0:
693
- ; LARGE-STATIC-NEXT: movabsq $unknown_size_data, %rax
694
- ; LARGE-STATIC-NEXT: movl 8 (%rax), %eax
700
+ ; LARGE-STATIC-NEXT: movabsq $unknown_size_data+8 , %rax
701
+ ; LARGE-STATIC-NEXT: movl (%rax), %eax
695
702
; LARGE-STATIC-NEXT: retq
696
703
;
697
704
; SMALL-PIC-LABEL: load_unknown_size_data:
@@ -1127,8 +1134,7 @@ define dso_local float @load_constant_pool(float %x) #0 {
1127
1134
;
1128
1135
; MEDIUM-STATIC-LABEL: load_constant_pool:
1129
1136
; MEDIUM-STATIC: # %bb.0:
1130
- ; MEDIUM-STATIC-NEXT: movl ${{\.?LCPI[0-9]+_[0-9]+}}, %eax
1131
- ; MEDIUM-STATIC-NEXT: addss (%rax), %xmm0
1137
+ ; MEDIUM-STATIC-NEXT: addss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1132
1138
; MEDIUM-STATIC-NEXT: retq
1133
1139
;
1134
1140
; LARGE-STATIC-LABEL: load_constant_pool:
0 commit comments