[llvm-commits] [llvm] r94518 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/X86/AsmPrinter/X86AsmPrinter.cpp

Chris Lattner sabre at nondot.org
Mon Jan 25 21:15:31 PST 2010


Author: lattner
Date: Mon Jan 25 23:15:20 2010
New Revision: 94518

URL: http://llvm.org/viewvc/llvm-project?rev=94518&view=rev
Log:
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.


Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94518&r1=94517&r2=94518&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan 25 23:15:20 2010
@@ -511,14 +511,16 @@
     // 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<MachineBasicBlock*, 16> 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<MachineBasicBlock*, 16> 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

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=94518&r1=94517&r2=94518&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Jan 25 23:15:20 2010
@@ -455,17 +455,8 @@
 
 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';





More information about the llvm-commits mailing list