summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp17
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp7
2 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 5a01e0e9b6f..aacc486aa14 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1178,14 +1178,23 @@ void AsmPrinter::EmitJumpTableInfo() {
// the appropriate section.
const Function *F = MF->getFunction();
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
- bool JTInDiffSection = !TLOF.shouldPutJumpTableInFunctionSection(
- MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
- *F);
- if (JTInDiffSection) {
+ bool JTInDiffSection = false;
+ if (// 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.
+ // FIXME: Need a better predicate for this: what about custom entries?
+ MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 ||
+ // We should also do if the section name is NULL or function is declared
+ // in discardable section
+ // FIXME: this isn't the right predicate, should be based on the MCSection
+ // for the function.
+ F->isWeakForLinker()) {
+ OutStreamer.SwitchSection(TLOF.SectionForGlobal(F, *Mang, TM));
+ } else {
// Otherwise, drop it in the readonly section.
const MCSection *ReadOnlySection =
TLOF.getSectionForJumpTable(*F, *Mang, TM);
OutStreamer.SwitchSection(ReadOnlySection);
+ JTInDiffSection = true;
}
EmitAlignment(Log2_32(
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 4f46e37d39c..0a49f5ff9fe 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -356,13 +356,6 @@ const MCSection *TargetLoweringObjectFileELF::getSectionForJumpTable(
return getContext().getELFSection(Name, ELF::SHT_PROGBITS, Flags, 0, Group);
}
-bool TargetLoweringObjectFileELF::shouldPutJumpTableInFunctionSection(
- bool UsesLabelDifference, const Function &F) const {
- // We can always create relative relocations, so use another section
- // that can be marked non-executable.
- return false;
-}
-
/// getSectionForConstant - Given a mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
OpenPOWER on IntegriCloud