Fix for PR1059: http://llvm.org/PR1059
authorAnton Korobeynikov <asl@math.spbu.ru>
Tue, 19 Dec 2006 21:04:20 +0000 (21:04 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Tue, 19 Dec 2006 21:04:20 +0000 (21:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32685 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp
lib/Target/X86/X86IntelAsmPrinter.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index 833ed28f085c4d48dd5d01ef5dd5564f4fd9f239..82e110a27536ac9de5342b33b6d6c8b5796d63d6 100644 (file)
@@ -214,14 +214,17 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
   TargetLowering *LoweringInfo = TM.getTargetLowering();
-  
-  if (IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) {
+
+  const char* JumpTableDataSection = TAI->getJumpTableDataSection();  
+  if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
+     !JumpTableDataSection) {
     // 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.
     const Function *F = MF.getFunction();
     SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
   } else {
-    SwitchToDataSection(TAI->getJumpTableDataSection());
+    SwitchToDataSection(JumpTableDataSection);
   }
   
   EmitAlignment(Log2_32(MJTI->getAlignment()));
index dd73a2d318148f8ba2e920a85f6b845ddb168fa3..142177c4ee22d0c339546865f6684600198b87b1 100755 (executable)
@@ -113,7 +113,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
                                  const char *Modifier) {
   const MRegisterInfo &RI = *TM.getRegisterInfo();
   switch (MO.getType()) {
-  case MachineOperand::MO_Register:
+  case MachineOperand::MO_Register: {      
     if (MRegisterInfo::isPhysicalRegister(MO.getReg())) {
       unsigned Reg = MO.getReg();
       if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
@@ -126,13 +126,20 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
     } else
       O << "reg" << MO.getReg();
     return;
-
+  }
   case MachineOperand::MO_Immediate:
     O << MO.getImmedValue();
     return;
   case MachineOperand::MO_MachineBasicBlock:
     printBasicBlockLabel(MO.getMachineBasicBlock());
     return;
+  case MachineOperand::MO_JumpTableIndex: {
+    bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
+    if (!isMemOp) O << "OFFSET ";
+    O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
+      << "_" << MO.getJumpTableIndex();
+    return;
+  }    
   case MachineOperand::MO_ConstantPoolIndex: {
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp) O << "OFFSET ";
index ed9f1ac313278fefdb6c3a0f2da9b96541f687e6..71640380348cdd521e9420127596ce5c6f5ebd92 100644 (file)
@@ -152,6 +152,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     
     TextSection = "_text";
     DataSection = "_data";
+    JumpTableDataSection = NULL;
     SwitchToSectionDirective = "";
     TextSectionStartSuffix = "\tsegment 'CODE'";
     DataSectionStartSuffix = "\tsegment 'DATA'";