[llvm] opaque (PR #74952)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 9 13:27:20 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
- [X86] Respect small/large globals when determining if we can use a 32-bit constant
- [X86] Handle unsized types in TargetMachine::isLargeGlobalObject()
---
Patch is 20.09 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74952.diff
3 Files Affected:
- (modified) llvm/lib/Target/TargetMachine.cpp (+2)
- (modified) llvm/lib/Target/X86/X86ISelDAGToDAG.cpp (+11-5)
- (modified) llvm/test/CodeGen/X86/code-model-elf.ll (+231-21)
``````````diff
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index ff496d29b39121..a4e84f38431ae9 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -78,6 +78,8 @@ bool TargetMachine::isLargeGlobalObject(const GlobalObject *GO) const {
if (getCodeModel() == CodeModel::Medium ||
getCodeModel() == CodeModel::Large) {
+ if (!GV->getValueType()->isSized())
+ return true;
const DataLayout &DL = GV->getParent()->getDataLayout();
uint64_t Size = DL.getTypeSizeInBits(GV->getValueType()) / 8;
return Size == 0 || Size > LargeDataThreshold;
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 545039b79f1616..cf014ecebe8487 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2943,12 +2943,18 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
if (N->getOpcode() != ISD::TargetGlobalAddress)
return TM.getCodeModel() == CodeModel::Small;
- std::optional<ConstantRange> CR =
- cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
- if (!CR)
- return TM.getCodeModel() == CodeModel::Small;
+ // Kernel uses upper half of address space.
+ if (TM.getCodeModel() == CodeModel::Kernel)
+ return false;
- return CR->getUnsignedMax().ult(1ull << 32);
+ const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
+ std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange();
+ if (CR)
+ return CR->getUnsignedMax().ult(1ull << 32);
+ // We can reference small globals with 32-bit constants.
+ if (auto *GO = GV->getAliaseeObject())
+ return !TM.isLargeGlobalObject(GO);
+ return false;
}
bool X86DAGToDAGISel::selectLEA64_32Addr(SDValue N, SDValue &Base,
diff --git a/llvm/test/CodeGen/X86/code-model-elf.ll b/llvm/test/CodeGen/X86/code-model-elf.ll
index 457c6bde354f2e..ac0decc57aef83 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -9,7 +9,7 @@
; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium -large-data-threshold=1000 | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-SMALL-DATA-PIC
; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-PIC
; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC
-; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large -large-data-threshold=1000 | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC
+; 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
; Generated from this C source:
;
@@ -36,11 +36,14 @@ source_filename = "model.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
+%t = type opaque
+
@global_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16
@static_data = internal global [10 x i32] zeroinitializer, align 16
@extern_data = external global [10 x i32], align 16
@thread_data = external thread_local global i32, align 4
@unknown_size_data = dso_local global [0 x i32] zeroinitializer, align 16
+ at opaque = external dso_local global %t
@forced_small_data = dso_local global [10 x i32] zeroinitializer, code_model "small", align 16
@forced_large_data = dso_local global [10 x i32] zeroinitializer, code_model "large", align 16
@@ -86,6 +89,16 @@ define dso_local ptr @lea_static_data() #0 {
; LARGE-PIC-NEXT: movabsq $static_data at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_static_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L0$pb:
+; 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: movl $static_data at GOTOFF, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @static_data
}
@@ -131,6 +144,16 @@ define dso_local ptr @lea_global_data() #0 {
; LARGE-PIC-NEXT: movabsq $global_data at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_global_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L1$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L1$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $global_data at GOTOFF, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @global_data
}
@@ -174,6 +197,16 @@ define dso_local ptr @lea_extern_data() #0 {
; LARGE-PIC-NEXT: movabsq $extern_data at GOT, %rax
; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_extern_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L2$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L2$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $extern_data at GOT, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: movq (%rcx,%rax), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @extern_data
}
@@ -221,10 +254,19 @@ define dso_local ptr @lea_unknown_size_data() #0 {
; LARGE-PIC-NEXT: movabsq $unknown_size_data at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_unknown_size_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L3$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L3$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $unknown_size_data at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @unknown_size_data
}
-; TODO: make nopic small and medium instruction sequence the same
define dso_local ptr @lea_forced_small_data() #0 {
; SMALL-STATIC-LABEL: lea_forced_small_data:
; SMALL-STATIC: # %bb.0:
@@ -233,12 +275,12 @@ define dso_local ptr @lea_forced_small_data() #0 {
;
; MEDIUM-STATIC-LABEL: lea_forced_small_data:
; MEDIUM-STATIC: # %bb.0:
-; MEDIUM-STATIC-NEXT: movabsq $forced_small_data, %rax
+; MEDIUM-STATIC-NEXT: movl $forced_small_data, %eax
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: lea_forced_small_data:
; LARGE-STATIC: # %bb.0:
-; LARGE-STATIC-NEXT: movabsq $forced_small_data, %rax
+; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
; LARGE-STATIC-NEXT: retq
;
; SMALL-PIC-LABEL: lea_forced_small_data:
@@ -262,9 +304,19 @@ define dso_local ptr @lea_forced_small_data() #0 {
; LARGE-PIC-NEXT: leaq .L4$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
-; LARGE-PIC-NEXT: movabsq $forced_small_data at GOTOFF, %rax
+; LARGE-PIC-NEXT: movl $forced_small_data at GOTOFF, %eax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_forced_small_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L4$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L4$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $forced_small_data at GOTOFF, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @forced_small_data
}
@@ -277,13 +329,13 @@ define dso_local i32 @load_forced_small_data() #0 {
;
; MEDIUM-STATIC-LABEL: load_forced_small_data:
; MEDIUM-STATIC: # %bb.0:
-; MEDIUM-STATIC-NEXT: movabsq $forced_small_data, %rax
+; MEDIUM-STATIC-NEXT: movl $forced_small_data, %eax
; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: load_forced_small_data:
; LARGE-STATIC: # %bb.0:
-; LARGE-STATIC-NEXT: movabsq $forced_small_data, %rax
+; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
; LARGE-STATIC-NEXT: movl 8(%rax), %eax
; LARGE-STATIC-NEXT: retq
;
@@ -310,9 +362,19 @@ define dso_local i32 @load_forced_small_data() #0 {
; LARGE-PIC-NEXT: leaq .L5$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L5$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
-; LARGE-PIC-NEXT: movabsq $forced_small_data at GOTOFF, %rax
+; LARGE-PIC-NEXT: movl $forced_small_data at GOTOFF, %eax
; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_forced_small_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L5$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L5$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L5$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $forced_small_data at GOTOFF, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: movl 8(%rcx,%rax), %eax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
%rv = load i32, ptr getelementptr inbounds (i32, ptr @forced_small_data, i64 2)
ret i32 %rv
}
@@ -321,7 +383,7 @@ define dso_local i32 @load_forced_small_data() #0 {
define dso_local ptr @lea_forced_large_data() #0 {
; SMALL-STATIC-LABEL: lea_forced_large_data:
; SMALL-STATIC: # %bb.0:
-; SMALL-STATIC-NEXT: movl $forced_large_data, %eax
+; SMALL-STATIC-NEXT: movabsq $forced_large_data, %rax
; SMALL-STATIC-NEXT: retq
;
; MEDIUM-STATIC-LABEL: lea_forced_large_data:
@@ -363,6 +425,16 @@ define dso_local ptr @lea_forced_large_data() #0 {
; LARGE-PIC-NEXT: movabsq $forced_large_data at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_forced_large_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L6$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L6$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L6$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $forced_large_data at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @forced_large_data
}
@@ -413,6 +485,16 @@ define dso_local i32 @load_forced_large_data() #0 {
; LARGE-PIC-NEXT: movabsq $forced_large_data at GOTOFF, %rax
; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_forced_large_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L7$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L7$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L7$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $forced_large_data at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movl 8(%rcx,%rax), %eax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
%rv = load i32, ptr getelementptr inbounds (i32, ptr @forced_large_data, i64 2)
ret i32 %rv
}
@@ -462,6 +544,16 @@ define dso_local i32 @load_global_data() #0 {
; LARGE-PIC-NEXT: movabsq $global_data at GOTOFF, %rax
; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_global_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L8$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L8$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L8$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $global_data at GOTOFF, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: movl 8(%rcx,%rax), %eax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
%rv = load i32, ptr getelementptr inbounds ([10 x i32], ptr @global_data, i64 0, i64 2)
ret i32 %rv
}
@@ -513,6 +605,17 @@ define dso_local i32 @load_extern_data() #0 {
; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax
; LARGE-PIC-NEXT: movl 8(%rax), %eax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_extern_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L9$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L9$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L9$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movl $extern_data at GOT, %eax
+; LARGE-SMALL-DATA-PIC-NEXT: movq (%rcx,%rax), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movl 8(%rax), %eax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
%rv = load i32, ptr getelementptr inbounds ([10 x i32], ptr @extern_data, i64 0, i64 2)
ret i32 %rv
}
@@ -563,10 +666,77 @@ define dso_local i32 @load_unknown_size_data() #0 {
; LARGE-PIC-NEXT: movabsq $unknown_size_data at GOTOFF, %rax
; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_unknown_size_data:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L10$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L10$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L10$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $unknown_size_data at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movl 8(%rcx,%rax), %eax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
%rv = load i32, ptr getelementptr inbounds (i32, ptr @unknown_size_data, i64 2)
ret i32 %rv
}
+define dso_local ptr @lea_opaque() #0 {
+; SMALL-STATIC-LABEL: lea_opaque:
+; SMALL-STATIC: # %bb.0:
+; SMALL-STATIC-NEXT: movl $opaque, %eax
+; SMALL-STATIC-NEXT: retq
+;
+; MEDIUM-STATIC-LABEL: lea_opaque:
+; MEDIUM-STATIC: # %bb.0:
+; MEDIUM-STATIC-NEXT: movabsq $opaque, %rax
+; MEDIUM-STATIC-NEXT: retq
+;
+; LARGE-STATIC-LABEL: lea_opaque:
+; LARGE-STATIC: # %bb.0:
+; LARGE-STATIC-NEXT: movabsq $opaque, %rax
+; LARGE-STATIC-NEXT: retq
+;
+; SMALL-PIC-LABEL: lea_opaque:
+; SMALL-PIC: # %bb.0:
+; SMALL-PIC-NEXT: leaq opaque(%rip), %rax
+; SMALL-PIC-NEXT: retq
+;
+; MEDIUM-SMALL-DATA-PIC-LABEL: lea_opaque:
+; MEDIUM-SMALL-DATA-PIC: # %bb.0:
+; MEDIUM-SMALL-DATA-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
+; MEDIUM-SMALL-DATA-PIC-NEXT: movabsq $opaque at GOTOFF, %rax
+; MEDIUM-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; MEDIUM-SMALL-DATA-PIC-NEXT: retq
+;
+; MEDIUM-PIC-LABEL: lea_opaque:
+; MEDIUM-PIC: # %bb.0:
+; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
+; MEDIUM-PIC-NEXT: movabsq $opaque at GOTOFF, %rax
+; MEDIUM-PIC-NEXT: addq %rcx, %rax
+; MEDIUM-PIC-NEXT: retq
+;
+; LARGE-PIC-LABEL: lea_opaque:
+; LARGE-PIC: # %bb.0:
+; LARGE-PIC-NEXT: .L11$pb:
+; LARGE-PIC-NEXT: leaq .L11$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L11$pb, %rcx
+; LARGE-PIC-NEXT: addq %rax, %rcx
+; LARGE-PIC-NEXT: movabsq $opaque at GOTOFF, %rax
+; LARGE-PIC-NEXT: addq %rcx, %rax
+; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_opaque:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L11$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L11$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L11$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $opaque at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
+ ret ptr @opaque
+}
+
define dso_local void @global_fn() #0 {
; CHECK-LABEL: global_fn:
; CHECK: # %bb.0:
@@ -616,13 +786,23 @@ define dso_local ptr @lea_static_fn() #0 {
;
; LARGE-PIC-LABEL: lea_static_fn:
; LARGE-PIC: # %bb.0:
-; LARGE-PIC-NEXT: .L13$pb:
-; LARGE-PIC-NEXT: leaq .L13$pb(%rip), %rax
-; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L13$pb, %rcx
+; LARGE-PIC-NEXT: .L14$pb:
+; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $static_fn at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_static_fn:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L14$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L14$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $static_fn at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @static_fn
}
@@ -659,13 +839,23 @@ define dso_local ptr @lea_global_fn() #0 {
;
; LARGE-PIC-LABEL: lea_global_fn:
; LARGE-PIC: # %bb.0:
-; LARGE-PIC-NEXT: .L14$pb:
-; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax
-; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx
+; LARGE-PIC-NEXT: .L15$pb:
+; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $global_fn at GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_global_fn:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L15$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L15$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $global_fn at GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @global_fn
}
@@ -702,13 +892,23 @@ define dso_local ptr @lea_extern_fn() #0 {
;
; LARGE-PIC-LABEL: lea_extern_fn:
; LARGE-PIC: # %bb.0:
-; LARGE-PIC-NEXT: .L15$pb:
-; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax
-; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx
+; LARGE-PIC-NEXT: .L16$pb:
+; LARGE-PIC-NEXT: leaq .L16$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $extern_fn at GOT, %rax
; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: lea_extern_fn:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L16$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L16$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $extern_fn at GOT, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movq (%rcx,%rax), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @extern_fn
}
@@ -780,13 +980,23 @@ define dso_local float @load_constant_pool(float %x) #0 {
;
; LARGE-PIC-LABEL: load_constant_pool:
; LARGE-PIC: # %bb.0:
-; LARGE-PIC-NEXT: .L17$pb:
-; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax
-; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx
+; LARGE-PIC-NEXT: .L18$pb:
+; LARGE-PIC-NEXT: leaq .L18$pb(%rip), %rax
+; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L18$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
; LARGE-PIC-NEXT: addss (%rcx,%rax), %xmm0
; LARGE-PIC-NEXT: retq
+;
+; LARGE-SMALL-DATA-PIC-LABEL: load_constant_pool:
+; LARGE-SMALL-DATA-PIC: # %bb.0:
+; LARGE-SMALL-DATA-PIC-NEXT: .L18$pb:
+; LARGE-SMALL-DATA-PIC-NEXT: leaq .L18$pb(%rip), %rax
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L18$pb, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
+; LARGE-SMALL-DATA-PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
+; LARGE-SMALL-DATA-PIC-NEXT: addss (%rcx,%rax), ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/74952
More information about the llvm-commits
mailing list