A MachineConstantPool may have mixed Constant* and MachineConstantPoolValue* values.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 14 Sep 2006 05:50:57 +0000 (05:50 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 14 Sep 2006 05:50:57 +0000 (05:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30316 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineFunction.cpp

index e07832435bf1cb317d6d88cd73928455b38d7093..0babf229a9b208cc64f51a1df1119c6ce8918bdb 100644 (file)
@@ -351,6 +351,12 @@ void MachineJumpTableInfo::dump() const { print(std::cerr); }
 //  MachineConstantPool implementation
 //===----------------------------------------------------------------------===//
 
+const Type *MachineConstantPoolEntry::getType() const {
+  if (isMachineConstantPoolEntry())
+      return Val.MachineCPVal->getType();
+  return Val.ConstVal->getType();
+}
+
 MachineConstantPool::~MachineConstantPool() {
   for (unsigned i = 0, e = Constants.size(); i != e; ++i)
     if (Constants[i].isMachineConstantPoolEntry())
@@ -376,7 +382,7 @@ unsigned MachineConstantPool::getConstantPoolIndex(Constant *C,
   unsigned Offset = 0;
   if (!Constants.empty()) {
     Offset = Constants.back().Offset;
-    Offset += TD->getTypeSize(Constants.back().Val.ConstVal->getType());
+    Offset += TD->getTypeSize(Constants.back().getType());
     Offset = (Offset+AlignMask)&~AlignMask;
   }
   
@@ -400,7 +406,7 @@ unsigned MachineConstantPool::getConstantPoolIndex(MachineConstantPoolValue *V,
   unsigned Offset = 0;
   if (!Constants.empty()) {
     Offset = Constants.back().Offset;
-    Offset += TD->getTypeSize(Constants.back().Val.MachineCPVal->getType());
+    Offset += TD->getTypeSize(Constants.back().getType());
     Offset = (Offset+AlignMask)&~AlignMask;
   }