[llvm] 6bbb73b - [X86] Fix determining if globals with size <8 bits are large (#84975)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 12:43:34 PDT 2024


Author: Arthur Eubanks
Date: 2024-03-12T12:43:29-07:00
New Revision: 6bbb73b4cbc89b7291a8088aaa635814a216fbf6

URL: https://github.com/llvm/llvm-project/commit/6bbb73b4cbc89b7291a8088aaa635814a216fbf6
DIFF: https://github.com/llvm/llvm-project/commit/6bbb73b4cbc89b7291a8088aaa635814a216fbf6.diff

LOG: [X86] Fix determining if globals with size <8 bits are large (#84975)

Previously any global under 8 bits would accidentally be considered 0
sized, which is considered a large global.

Added: 
    

Modified: 
    llvm/lib/Target/TargetMachine.cpp
    llvm/test/CodeGen/X86/code-model-elf.ll

Removed: 
    


################################################################################
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