Skip to content

Commit

Permalink
Revert "[X86] Respect code_model when determining if a global is smal…
Browse files Browse the repository at this point in the history
…l/large (llvm#74498)"

This reverts commit ddebce7.
  • Loading branch information
Zentrik committed Jul 7, 2024
1 parent c27b24f commit f4c6ef7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
10 changes: 0 additions & 10 deletions llvm/lib/Target/TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ bool TargetMachine::isLargeGlobalObject(const GlobalObject *GO) const {
if (IsPrefix(".bss") || IsPrefix(".data") || IsPrefix(".rodata"))
return false;

// For x86-64, we treat an explicit GlobalVariable small code model to mean
// that the global should be placed in a small section, and ditto for large.
// Well-known section names above take precedence for correctness.
if (auto CM = GV->getCodeModel()) {
if (*CM == CodeModel::Small)
return false;
if (*CM == CodeModel::Large)
return true;
}

if (getCodeModel() == CodeModel::Medium ||
getCodeModel() == CodeModel::Large) {
const DataLayout &DL = GV->getParent()->getDataLayout();
Expand Down
13 changes: 5 additions & 8 deletions llvm/test/CodeGen/X86/code-model-elf-sections.ll
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
; SMALL: .data {{.*}} WA {{.*}}
; SMALL: .data.x {{.*}} WA {{.*}}
; SMALL: .data0 {{.*}} WA {{.*}}
; SMALL: .ldata {{.*}} WAl {{.*}}
; SMALL: .ldata.x {{.*}} WAl {{.*}}
; SMALL: .ldata0 {{.*}} WA {{.*}}
; SMALL: foo {{.*}} WA {{.*}}
; SMALL: .bss {{.*}} WA {{.*}}
; SMALL: .rodata {{.*}} A {{.*}}
Expand All @@ -32,8 +35,6 @@
; SMALL-DS: .data.x {{.*}} WA {{.*}}
; SMALL-DS: .data0 {{.*}} WA {{.*}}
; SMALL-DS: .data.data {{.*}} WA {{.*}}
; SMALL-DS: force_small {{.*}} WA {{.*}}
; SMALL-DS: force_large {{.*}} WAl {{.*}}
; SMALL-DS: foo {{.*}} WA {{.*}}
; SMALL-DS: .bss.bss {{.*}} WA {{.*}}
; SMALL-DS: .rodata.rodata {{.*}} A {{.*}}
Expand All @@ -45,6 +46,8 @@
; LARGE: .data.x {{.*}} WA {{.*}}
; LARGE: .data0 {{.*}} WAl {{.*}}
; LARGE: .ldata {{.*}} WAl {{.*}}
; LARGE: .ldata.x {{.*}} WAl {{.*}}
; LARGE: .ldata0 {{.*}} WAl {{.*}}
; LARGE: foo {{.*}} WAl {{.*}}
; LARGE: .bss {{.*}} WA {{.*}}
; LARGE: .lbss {{.*}} WAl {{.*}}
Expand All @@ -58,8 +61,6 @@
; LARGE-DS: .data.x {{.*}} WA {{.*}}
; LARGE-DS: .data0 {{.*}} WAl {{.*}}
; LARGE-DS: .ldata.data {{.*}} WAl {{.*}}
; LARGE-DS: force_small {{.*}} WA {{.*}}
; LARGE-DS: force_large {{.*}} WAl {{.*}}
; LARGE-DS: foo {{.*}} WAl {{.*}}
; LARGE-DS: .bss {{.*}} WA {{.*}}
; LARGE-DS: .lbss.bss {{.*}} WAl {{.*}}
Expand All @@ -76,10 +77,6 @@ target triple = "x86_64--linux"
@data_with_explicit_section2 = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], section ".data.x"
@data_with_explicit_section0 = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], section ".data0"
@data = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0]
@data_force_small = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], code_model "small", section "force_small"
@data_force_large = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], code_model "large", section "force_large"
@data_force_small_ldata = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], code_model "small", section ".ldata"
@data_force_large_data = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], code_model "large", section ".data"
@foo_with_explicit_section = internal global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0], section "foo"
@bss_with_explicit_section = internal global [10 x i64] zeroinitializer, section ".bss"
@bss = internal global [10 x i64] zeroinitializer
Expand Down

0 comments on commit f4c6ef7

Please sign in to comment.