Make MachineConstantPool entries alignments explicit
authorChris Lattner <sabre@nondot.org>
Thu, 9 Feb 2006 02:23:13 +0000 (02:23 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 9 Feb 2006 02:23:13 +0000 (02:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/ScheduleDAG.cpp

index 157487056909ae4a168078460b5c049111518fe7..ff4ae335f2de19871951577d30069bad9e814d39 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/Target/TargetInstrItineraries.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Constant.h"
 #include <iostream>
 using namespace llvm;
 
@@ -194,8 +195,17 @@ void ScheduleDAG::EmitNode(NodeInfo *NI) {
         MI->addFrameIndexOperand(FI->getIndex());
       } else if (ConstantPoolSDNode *CP = 
                     dyn_cast<ConstantPoolSDNode>(Node->getOperand(i))) {
-        unsigned Idx = ConstPool->getConstantPoolIndex(CP->get(),
-                                                       CP->getAlignment());
+        unsigned Align = CP->getAlignment();
+        // MachineConstantPool wants an explicit alignment.
+        if (Align == 0) {
+          if (CP->get()->getType() == Type::DoubleTy)
+            Align = 3;  // always 8-byte align doubles.
+          else
+            Align = TM.getTargetData()
+              .getTypeAlignmentShift(CP->get()->getType());
+        }
+        
+        unsigned Idx = ConstPool->getConstantPoolIndex(CP->get(), Align);
         MI->addConstantPoolIndexOperand(Idx);
       } else if (ExternalSymbolSDNode *ES = 
                  dyn_cast<ExternalSymbolSDNode>(Node->getOperand(i))) {