Allow the specification of explicit alignments for constant pool entries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25855 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index ab0465d..df00f47 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -103,7 +103,7 @@
/// the code generator.
///
void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
- const std::vector<Constant*> &CP = MCP->getConstants();
+ const std::vector<std::pair<Constant*, unsigned> > &CP = MCP->getConstants();
if (CP.empty()) return;
const TargetData &TD = TM.getTargetData();
@@ -111,13 +111,17 @@
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
// FIXME: force doubles to be naturally aligned. We should handle this
// more correctly in the future.
- unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
- if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+ unsigned Alignment = CP[i].second;
+ if (Alignment == 0) {
+ Alignment = TD.getTypeAlignmentShift(CP[i].first->getType());
+ if (CP[i].first->getType() == Type::DoubleTy && Alignment < 3)
+ Alignment = 3;
+ }
EmitAlignment(Alignment);
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
- << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
- EmitGlobalConstant(CP[i]);
+ << ":\t\t\t\t\t" << CommentString << *CP[i].first << '\n';
+ EmitGlobalConstant(CP[i].first);
}
}