[llvm] 922700d - Revert "[X86] Change how we treat functions with explicit sections as small/large (#87838)"
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 16:00:27 PDT 2024
Author: Arthur Eubanks
Date: 2024-04-08T23:00:01Z
New Revision: 922700df44b7fd93dfaf642567283b2b7482e5df
URL: https://github.com/llvm/llvm-project/commit/922700df44b7fd93dfaf642567283b2b7482e5df
DIFF: https://github.com/llvm/llvm-project/commit/922700df44b7fd93dfaf642567283b2b7482e5df.diff
LOG: Revert "[X86] Change how we treat functions with explicit sections as small/large (#87838)"
This reverts commit e27c3736f975ca463476223c465e4777186f603f.
Breaks ExecutionEngine/MCJIT/test-global-ctors.ll on windows, e.g. https://lab.llvm.org/buildbot/#/builders/117/builds/18749.
Added:
Modified:
llvm/lib/Target/TargetMachine.cpp
llvm/test/CodeGen/X86/code-model-elf-text-sections.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 61abb85b6458f6..a7fe329b064ee1 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -51,20 +51,9 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
auto *GV = dyn_cast<GlobalVariable>(GO);
- auto IsPrefix = [](StringRef Name, StringRef Prefix) {
- return Name.consume_front(Prefix) && (Name.empty() || Name[0] == '.');
- };
-
// Functions/GlobalIFuncs are only large under the large code model.
- if (!GV) {
- // Handle explicit sections as we do for GlobalVariables with an explicit
- // section, see comments below.
- if (GO->hasSection()) {
- StringRef Name = GO->getSection();
- return IsPrefix(Name, ".ltext");
- }
+ if (!GV)
return getCodeModel() == CodeModel::Large;
- }
if (GV->isThreadLocal())
return false;
@@ -84,8 +73,11 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
// data sections. The code model attribute overrides this above.
if (GV->hasSection()) {
StringRef Name = GV->getSection();
- return IsPrefix(Name, ".lbss") || IsPrefix(Name, ".ldata") ||
- IsPrefix(Name, ".lrodata");
+ auto IsPrefix = [&](StringRef Prefix) {
+ StringRef S = Name;
+ return S.consume_front(Prefix) && (S.empty() || S[0] == '.');
+ };
+ return IsPrefix(".lbss") || IsPrefix(".ldata") || IsPrefix(".lrodata");
}
// Respect large data threshold for medium and large code models.
diff --git a/llvm/test/CodeGen/X86/code-model-elf-text-sections.ll b/llvm/test/CodeGen/X86/code-model-elf-text-sections.ll
index 66a6fd37675427..016c9a4d7b8390 100644
--- a/llvm/test/CodeGen/X86/code-model-elf-text-sections.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf-text-sections.ll
@@ -13,20 +13,9 @@
; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=LARGE-DS
; SMALL: .text {{.*}} AX {{.*}}
-; SMALL: .ltext {{.*}} AXl {{.*}}
-; SMALL: .ltext.2 {{.*}} AXl {{.*}}
-; SMALL: .foo {{.*}} AX {{.*}}
; SMALL-DS: .text.func {{.*}} AX {{.*}}
-; SMALL-DS: .ltext {{.*}} AXl {{.*}}
-; SMALL-DS: .ltext.2 {{.*}} AXl {{.*}}
-; SMALL-DS: .foo {{.*}} AX {{.*}}
; LARGE: .ltext {{.*}} AXl {{.*}}
-; LARGE: .ltext.2 {{.*}} AXl {{.*}}
-; LARGE: .foo {{.*}} AX {{.*}}
; LARGE-DS: .ltext.func {{.*}} AXl {{.*}}
-; LARGE-DS: .ltext {{.*}} AXl {{.*}}
-; LARGE-DS: .ltext.2 {{.*}} AXl {{.*}}
-; LARGE-DS: .foo {{.*}} AX {{.*}}
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
@@ -34,15 +23,3 @@ target triple = "x86_64--linux"
define void @func() {
ret void
}
-
-define void @ltext() section ".ltext" {
- ret void
-}
-
-define void @ltext2() section ".ltext.2" {
- ret void
-}
-
-define void @foo() section ".foo" {
- ret void
-}
More information about the llvm-commits
mailing list