aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-01 23:46:12 +0000
committerChris Lattner <sabre@nondot.org>2009-08-01 23:46:12 +0000
commit83d77faf6e8fc2c1c2377d037283dc162d8667a1 (patch)
treecd4f74cf10362426bfb894be3eb9b94b3d8c3fde /lib/CodeGen
parent0da3f4f742bd70e4f12d2f16f766f978417683f1 (diff)
Remove "JumpTableDataSection" from TAI, instead, have AsmPrinter
compute it based on what it knows. As part of this, rename getSectionForMergeableConstant to getSectionForConstant because it works for non-mergable constants also. The only functionality change from this is that Xcore will start dropping its jump tables into readonly section instead of data section in -static mode. This should be fine as the linker resolves the relocations. If this is a problem, let me know and we'll come up with another solution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp20
-rw-r--r--lib/CodeGen/ELFWriter.cpp10
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 7c9fcf5fd6..f9839ddc68 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -349,8 +349,7 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
}
}
- const MCSection *S =
- getObjFileLowering().getSectionForMergeableConstant(Kind);
+ const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
// The number of sections are small, just do a linear search from the
// last section to the first.
@@ -419,22 +418,21 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
// the appropriate section.
TargetLowering *LoweringInfo = TM.getTargetLowering();
- const char *JumpTableDataSection = TAI->getJumpTableDataSection();
const Function *F = MF.getFunction();
-
- const MCSection *FuncSection =
- getObjFileLowering().SectionForGlobal(F, Mang, TM);
-
bool JTInDiffSection = false;
- if ((IsPic && !LoweringInfo->usesGlobalOffsetTable()) ||
- !JumpTableDataSection || F->isWeakForLinker()) {
+ if (F->isWeakForLinker() ||
+ (IsPic && !LoweringInfo->usesGlobalOffsetTable())) {
// In PIC mode, we need to emit the jump table to the same section as the
// function body itself, otherwise the label differences won't make sense.
// We should also do if the section name is NULL or function is declared in
// discardable section.
- SwitchToSection(FuncSection);
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
} else {
- SwitchToDataSection(JumpTableDataSection);
+ // Otherwise, drop it in the readonly section.
+ const MCSection *ReadOnlySection =
+ getObjFileLowering().getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly));
+ SwitchToSection(ReadOnlySection);
JTInDiffSection = true;
}
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index 1d33c7e1fe..be1e6bfe75 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/lib/CodeGen/ELFWriter.cpp
@@ -178,7 +178,13 @@ void ELFWriter::addExternalSymbol(const char *External) {
// Get jump table section on the section name returned by TAI
ELFSection &ELFWriter::getJumpTableSection() {
unsigned Align = TM.getTargetData()->getPointerABIAlignment();
- return getSection(TAI->getJumpTableDataSection(),
+
+ const TargetLoweringObjectFile &TLOF =
+ TM.getTargetLowering()->getObjFileLowering();
+
+ return getSection(TLOF.getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly))
+ ->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_ALLOC, Align);
}
@@ -204,7 +210,7 @@ ELFSection &ELFWriter::getConstantPoolSection(MachineConstantPoolEntry &CPE) {
const TargetLoweringObjectFile &TLOF =
TM.getTargetLowering()->getObjFileLowering();
- return getSection(TLOF.getSectionForMergeableConstant(Kind)->getName(),
+ return getSection(TLOF.getSectionForConstant(Kind)->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
CPE.getAlignment());