summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86AsmPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/X86/X86AsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/X86/X86AsmPrinter.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 75003e6b748..ad9a1e8e9f0 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -145,7 +145,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer();
- unsigned Size = TD->getTypeSize(C->getType());
+ const Type *Type = C->getType();
+ unsigned Size = TD->getTypeSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(I);
if (I->hasHiddenVisibility())
@@ -250,8 +251,28 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
} else {
if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
SwitchToDataSection(TAI->getBSSSection(), I);
- else
+ else if (!I->isConstant())
SwitchToDataSection(TAI->getDataSection(), I);
+ else {
+ // Read-only data.
+ bool isIntFPLiteral = Type->isInteger() || Type->isFloatingPoint();
+ if (C->ContainsRelocations() && Subtarget->isTargetDarwin() &&
+ TM.getRelocationModel() != Reloc::Static)
+ SwitchToDataSection("\t.const_data\n");
+ else if (isIntFPLiteral && Size == 4 &&
+ TAI->getFourByteConstantSection())
+ SwitchToDataSection(TAI->getFourByteConstantSection(), I);
+ else if (isIntFPLiteral && Size == 8 &&
+ TAI->getEightByteConstantSection())
+ SwitchToDataSection(TAI->getEightByteConstantSection(), I);
+ else if (isIntFPLiteral && Size == 16 &&
+ TAI->getSixteenByteConstantSection())
+ SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
+ else if (TAI->getReadOnlySection())
+ SwitchToDataSection(TAI->getReadOnlySection(), I);
+ else
+ SwitchToDataSection(TAI->getDataSection(), I);
+ }
}
break;
OpenPOWER on IntegriCloud