[llvm] [X86] Treat all data under large code model as large (PR #70265)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 14:09:31 PST 2023


https://github.com/aeubanks updated https://github.com/llvm/llvm-project/pull/70265

>From 63d45320c9b52550e1c05a055197172bb555d63f Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Wed, 25 Oct 2023 15:00:06 -0700
Subject: [PATCH] [X86] Treat all data under large code model as large

This allows better interoperability mixing small/medium/large code model
code since small code model data won't be mixed with large code model
data.
---
 llvm/lib/Target/TargetMachine.cpp                | 5 ++---
 llvm/test/CodeGen/X86/code-model-elf-sections.ll | 6 ++++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 9dc00ff85e009be..1cba8cf8004bfb4 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -42,9 +42,8 @@ TargetMachine::~TargetMachine() = default;
 bool TargetMachine::isLargeData(const GlobalVariable *GV) const {
   if (getTargetTriple().getArch() != Triple::x86_64 || GV->isThreadLocal())
     return false;
-  // Large data under the large code model still needs to be thought about, so
-  // restrict this to medium.
-  if (getCodeModel() != CodeModel::Medium)
+
+  if (getCodeModel() != CodeModel::Medium && getCodeModel() != CodeModel::Large)
     return false;
 
   // Allowing large metadata sections in the presence of an explicit section is
diff --git a/llvm/test/CodeGen/X86/code-model-elf-sections.ll b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
index 5f579edc440d6b2..0b99a70c4044af7 100644
--- a/llvm/test/CodeGen/X86/code-model-elf-sections.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
@@ -6,7 +6,9 @@
 ; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=LARGE
 ; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=medium -large-data-threshold=80 -o %t
 ; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SMALL
-; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=large -o %t
+; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=large -large-data-threshold=79 -o %t
+; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=LARGE
+; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=large -large-data-threshold=80 -o %t
 ; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SMALL
 
 ; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=small -data-sections -o %t
@@ -14,7 +16,7 @@
 ; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=medium -data-sections -o %t
 ; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=LARGE-DS
 ; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=large -data-sections -o %t
-; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SMALL-DS
+; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=LARGE-DS
 
 ; SMALL: .data {{.*}} WA {{.*}}
 ; SMALL: .data.x {{.*}} WA {{.*}}



More information about the llvm-commits mailing list