aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorQingShan Zhang <qshanz@cn.ibm.com>2021-01-05 03:22:45 +0000
committerQingShan Zhang <qshanz@cn.ibm.com>2021-01-05 03:22:45 +0000
commit2962f1149c8fccf8e865654ce11b3f1312165651 (patch)
tree1e19ec743603f72e95872967f905fef28d8fb265 /llvm/lib/CodeGen/MachineFunction.cpp
parentd51d72bbb91bf1179e58a40998efb3be6bb1ca6f (diff)
downloadllvm-2962f1149c8fccf8e865654ce11b3f1312165651.zip
llvm-2962f1149c8fccf8e865654ce11b3f1312165651.tar.gz
llvm-2962f1149c8fccf8e865654ce11b3f1312165651.tar.bz2
[NFC] Add the getSizeInBytes() interface for MachineConstantPoolValue
Current implementation assumes that, each MachineConstantPoolValue takes up sizeof(MachineConstantPoolValue::Ty) bytes. For PowerPC, we want to lump all the constants with the same type as one MachineConstantPoolValue to save the cost that calculate the TOC entry for each const. So, we need to extend the MachineConstantPoolValue that break this assumption. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D89108
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 1eb1914..3f44578 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -1107,10 +1107,14 @@ Printable llvm::printJumpTableEntryReference(unsigned Idx) {
void MachineConstantPoolValue::anchor() {}
-Type *MachineConstantPoolEntry::getType() const {
+unsigned MachineConstantPoolValue::getSizeInBytes(const DataLayout &DL) const {
+ return DL.getTypeAllocSize(Ty);
+}
+
+unsigned MachineConstantPoolEntry::getSizeInBytes(const DataLayout &DL) const {
if (isMachineConstantPoolEntry())
- return Val.MachineCPVal->getType();
- return Val.ConstVal->getType();
+ return Val.MachineCPVal->getSizeInBytes(DL);
+ return DL.getTypeAllocSize(Val.ConstVal->getType());
}
bool MachineConstantPoolEntry::needsRelocation() const {
@@ -1123,7 +1127,7 @@ SectionKind
MachineConstantPoolEntry::getSectionKind(const DataLayout *DL) const {
if (needsRelocation())
return SectionKind::getReadOnlyWithRel();
- switch (DL->getTypeAllocSize(getType())) {
+ switch (getSizeInBytes(*DL)) {
case 4:
return SectionKind::getMergeableConst4();
case 8: