[llvm] [X86] Fix determining if globals with size <8 bits are large (PR #84975)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 12:21:04 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
Previously any global under 8 bits would accidentally be considered 0 sized, which is considered a large global.
---
Full diff: https://github.com/llvm/llvm-project/pull/84975.diff
2 Files Affected:
- (modified) llvm/lib/Target/TargetMachine.cpp (+1-1)
- (modified) llvm/test/CodeGen/X86/code-model-elf.ll (+1-3)
``````````diff
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:
``````````
</details>
https://github.com/llvm/llvm-project/pull/84975
More information about the llvm-commits
mailing list