aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineConstantPool.h
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-03-13 07:51:59 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-03-13 07:51:59 +0000
commit1606e8e4cd937e6de6681f686c266cf61722d972 (patch)
tree0d2dbc91243124186225e830c6b575acc009f33f /include/llvm/CodeGen/MachineConstantPool.h
parent79a5cef503c54f07be27c078267df6170cc6390a (diff)
downloadexternal_llvm-1606e8e4cd937e6de6681f686c266cf61722d972.zip
external_llvm-1606e8e4cd937e6de6681f686c266cf61722d972.tar.gz
external_llvm-1606e8e4cd937e6de6681f686c266cf61722d972.tar.bz2
Fix some significant problems with constant pools that resulted in unnecessary paddings between constant pool entries, larger than necessary alignments (e.g. 8 byte alignment for .literal4 sections), and potentially other issues.
1. ConstantPoolSDNode alignment field is log2 value of the alignment requirement. This is not consistent with other SDNode variants. 2. MachineConstantPool alignment field is also a log2 value. 3. However, some places are creating ConstantPoolSDNode with alignment value rather than log2 values. This creates entries with artificially large alignments, e.g. 256 for SSE vector values. 4. Constant pool entry offsets are computed when they are created. However, asm printer group them by sections. That means the offsets are no longer valid. However, asm printer uses them to determine size of padding between entries. 5. Asm printer uses expensive data structure multimap to track constant pool entries by sections. 6. Asm printer iterate over SmallPtrSet when it's emitting constant pool entries. This is non-deterministic. Solutions: 1. ConstantPoolSDNode alignment field is changed to keep non-log2 value. 2. MachineConstantPool alignment field is also changed to keep non-log2 value. 3. Functions that create ConstantPool nodes are passing in non-log2 alignments. 4. MachineConstantPoolEntry no longer keeps an offset field. It's replaced with an alignment field. Offsets are not computed when constant pool entries are created. They are computed on the fly in asm printer and JIT. 5. Asm printer uses cheaper data structure to group constant pool entries. 6. Asm printer compute entry offsets after grouping is done. 7. Change JIT code to compute entry offsets on the fly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineConstantPool.h')
-rw-r--r--include/llvm/CodeGen/MachineConstantPool.h30
1 files changed, 14 insertions, 16 deletions
diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h
index d042258..d5bd25c 100644
--- a/include/llvm/CodeGen/MachineConstantPool.h
+++ b/include/llvm/CodeGen/MachineConstantPool.h
@@ -70,28 +70,26 @@ public:
MachineConstantPoolValue *MachineCPVal;
} Val;
- /// The offset of the constant from the start of the pool. The top bit is set
- /// when Val is a MachineConstantPoolValue.
- unsigned Offset;
+ /// The required alignment for this entry. The top bit is set when Val is
+ /// a MachineConstantPoolValue.
+ unsigned Alignment;
- MachineConstantPoolEntry(Constant *V, unsigned O)
- : Offset(O) {
- assert((int)Offset >= 0 && "Offset is too large");
+ MachineConstantPoolEntry(Constant *V, unsigned A)
+ : Alignment(A) {
Val.ConstVal = V;
}
- MachineConstantPoolEntry(MachineConstantPoolValue *V, unsigned O)
- : Offset(O){
- assert((int)Offset >= 0 && "Offset is too large");
+ MachineConstantPoolEntry(MachineConstantPoolValue *V, unsigned A)
+ : Alignment(A) {
Val.MachineCPVal = V;
- Offset |= 1 << (sizeof(unsigned)*8-1);
+ Alignment |= 1 << (sizeof(unsigned)*8-1);
}
bool isMachineConstantPoolEntry() const {
- return (int)Offset < 0;
+ return (int)Alignment < 0;
}
- int getOffset() const {
- return Offset & ~(1 << (sizeof(unsigned)*8-1));
+ int getAlignment() const {
+ return Alignment & ~(1 << (sizeof(unsigned)*8-1));
}
const Type *getType() const;
@@ -117,13 +115,13 @@ public:
: TD(td), PoolAlignment(1) {}
~MachineConstantPool();
- /// getConstantPoolAlignment - Return the log2 of the alignment required by
+ /// getConstantPoolAlignment - Return the the alignment required by
/// the whole constant pool, of which the first element must be aligned.
unsigned getConstantPoolAlignment() const { return PoolAlignment; }
/// getConstantPoolIndex - Create a new entry in the constant pool or return
- /// an existing one. User must specify the log2 of the minimum required
- /// alignment for the object.
+ /// an existing one. User must specify the minimum required alignment for
+ /// the object.
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
unsigned getConstantPoolIndex(MachineConstantPoolValue *V,unsigned Alignment);