[llvm] [X86] Fix determining if globals with size <8 bits are large (PR #84975)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 12:20:34 PDT 2024
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/84975
Previously any global under 8 bits would accidentally be considered 0 sized, which is considered a large global.
>From ddb7a13c5cb010fc5e8a2d9dabaebec875decc77 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Tue, 12 Mar 2024 19:12:02 +0000
Subject: [PATCH] [X86] Fix determining if globals with size <8 bits are large
Previously any global under 8 bits would accidentally be considered 0 sized, which is considered a large global.
---
llvm/lib/Target/TargetMachine.cpp | 2 +-
llvm/test/CodeGen/X86/code-model-elf.ll | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 8b177a89c9192b..a7fe329b064ee1 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -92,7 +92,7 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
GV->getName().starts_with("__stop_")))
return true;
const DataLayout &DL = GV->getParent()->getDataLayout();
- uint64_t Size = DL.getTypeSizeInBits(GV->getValueType()) / 8;
+ uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
return Size == 0 || Size > LargeDataThreshold;
}
diff --git a/llvm/test/CodeGen/X86/code-model-elf.ll b/llvm/test/CodeGen/X86/code-model-elf.ll
index 4e96d39d153f8c..0da62e3e7a6519 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -772,9 +772,7 @@ define dso_local i1 @load_bool() #0 {
;
; MEDIUM-SMALL-DATA-PIC-LABEL: load_bool:
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
-; MEDIUM-SMALL-DATA-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
-; MEDIUM-SMALL-DATA-PIC-NEXT: movabsq $bool at GOTOFF, %rcx
-; MEDIUM-SMALL-DATA-PIC-NEXT: movzbl (%rax,%rcx), %eax
+; MEDIUM-SMALL-DATA-PIC-NEXT: movzbl bool(%rip), %eax
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
;
; MEDIUM-PIC-LABEL: load_bool:
More information about the llvm-commits
mailing list