[llvm] [X86] Respect code models more when determining if a global reference can fit in 32 bits (PR #75386)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 16:25:26 PST 2023
================
@@ -96,12 +97,67 @@ define dso_local ptr @lea_static_data() #0 {
; LARGE-SMALL-DATA-PIC-NEXT: leaq .L0$pb(%rip), %rax
; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx
; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
-; LARGE-SMALL-DATA-PIC-NEXT: movabsq $static_data at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movl $static_data at GOTOFF, %eax
; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @static_data
}
+define dso_local ptr @lea_static_data_alias() #0 {
+; SMALL-STATIC-LABEL: lea_static_data_alias:
+; SMALL-STATIC: # %bb.0:
+; SMALL-STATIC-NEXT: movl $static_data_alias, %eax
+; SMALL-STATIC-NEXT: retq
+;
+; MEDIUM-STATIC-LABEL: lea_static_data_alias:
+; MEDIUM-STATIC: # %bb.0:
+; MEDIUM-STATIC-NEXT: movabsq $static_data_alias, %rax
+; MEDIUM-STATIC-NEXT: retq
+;
+; LARGE-STATIC-LABEL: lea_static_data_alias:
+; LARGE-STATIC: # %bb.0:
+; LARGE-STATIC-NEXT: movabsq $static_data_alias, %rax
+; LARGE-STATIC-NEXT: retq
+;
+; SMALL-PIC-LABEL: lea_static_data_alias:
+; SMALL-PIC: # %bb.0:
+; SMALL-PIC-NEXT: leaq static_data_alias(%rip), %rax
+; SMALL-PIC-NEXT: retq
+;
+; MEDIUM-SMALL-DATA-PIC-LABEL: lea_static_data_alias:
+; MEDIUM-SMALL-DATA-PIC: # %bb.0:
+; MEDIUM-SMALL-DATA-PIC-NEXT: leaq static_data_alias(%rip), %rax
+; MEDIUM-SMALL-DATA-PIC-NEXT: retq
+;
+; MEDIUM-PIC-LABEL: lea_static_data_alias:
+; MEDIUM-PIC: # %bb.0:
+; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
+; MEDIUM-PIC-NEXT: movabsq $static_data_alias at GOTOFF, %rax
+; MEDIUM-PIC-NEXT: addq %rcx, %rax
+; MEDIUM-PIC-NEXT: retq
+;
+; LARGE-PIC-LABEL: lea_static_data_alias:
+; LARGE-PIC: # %bb.0:
+; LARGE-PIC-NEXT: .L1$pb:
+; LARGE-PIC-NEXT: leaq .L1$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx
----------------
rnk wrote:
The large PIC code model is awful. Is there really no way to express `$static_data_alias - .L1$pb` with a static relocation? That would avoid the need for the second add and i64 materialization.
https://github.com/llvm/llvm-project/pull/75386
More information about the llvm-commits
mailing list