From e35df92eca194365f984f9d24a74e4ddd6669c40 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 26 Jan 2010 05:15:20 +0000 Subject: [PATCH] simplify asmprinter: only emit .set directives when entries have EK_LabelDifference32 kind and the target has .set support. Simplify X86AsmPrinter::printPICJumpTableSetLabel to make use of recent helpers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94518 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 12 +++++++----- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 13 ++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 1b58f1ab00f..c1b45c3917c 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -511,14 +511,16 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) { // If this jump table was deleted, ignore it. if (JTBBs.empty()) continue; - // For PIC codegen, if possible we want to use the SetDirective to reduce - // the number of relocations the assembler will generate for the jump table. - // Set directives are all printed before the jump table itself. - SmallPtrSet EmittedSets; - if (MAI->getSetDirective() && IsPic) + // For the EK_LabelDifference32 entry, if the target supports .set, emit a + // .set directive for each unique entry. This reduces the number of + // relocations the assembler will generate for the jump table. + if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 && + MAI->getSetDirective()) { + SmallPtrSet EmittedSets; for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) if (EmittedSets.insert(JTBBs[ii])) printPICJumpTableSetLabel(i, JTBBs[ii]); + } // On some targets (e.g. Darwin) we want to emit two consequtive labels // before each jump table. The first label is never referenced, but tells diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index cc124139020..9f1424b7cbc 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -455,17 +455,8 @@ void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op, void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid, const MachineBasicBlock *MBB) const { - if (!MAI->getSetDirective()) - return; - - // We don't need .set machinery if we have GOT-style relocations - if (Subtarget->isPICStyleGOT()) // X86-32 on ELF. - return; - - O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() - << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','; - - O << *MBB->getSymbol(OutContext); + O << MAI->getSetDirective() << ' ' << *GetJTSetSymbol(uid, MBB->getNumber()) + << ',' << *MBB->getSymbol(OutContext); if (Subtarget->isPICStyleRIPRel()) O << '-' << *GetJTISymbol(uid) << '\n';