Skip to content

Commit 6bbb73b

Browse files
authored
[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.
1 parent a38b7a4 commit 6bbb73b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

llvm/lib/Target/TargetMachine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
9292
GV->getName().starts_with("__stop_")))
9393
return true;
9494
const DataLayout &DL = GV->getParent()->getDataLayout();
95-
uint64_t Size = DL.getTypeSizeInBits(GV->getValueType()) / 8;
95+
uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
9696
return Size == 0 || Size > LargeDataThreshold;
9797
}
9898

llvm/test/CodeGen/X86/code-model-elf.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,7 @@ define dso_local i1 @load_bool() #0 {
772772
;
773773
; MEDIUM-SMALL-DATA-PIC-LABEL: load_bool:
774774
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
775-
; MEDIUM-SMALL-DATA-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
776-
; MEDIUM-SMALL-DATA-PIC-NEXT: movabsq $bool@GOTOFF, %rcx
777-
; MEDIUM-SMALL-DATA-PIC-NEXT: movzbl (%rax,%rcx), %eax
775+
; MEDIUM-SMALL-DATA-PIC-NEXT: movzbl bool(%rip), %eax
778776
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
779777
;
780778
; MEDIUM-PIC-LABEL: load_bool:

0 commit comments

Comments
 (0)