[llvm] r290714 - Revert "[COFF] Use 32-bit jump table entries in .rdata for Win64"

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 09:07:11 PST 2016


Author: rnk
Date: Thu Dec 29 11:07:10 2016
New Revision: 290714

URL: http://llvm.org/viewvc/llvm-project?rev=290714&view=rev
Log:
Revert "[COFF] Use 32-bit jump table entries in .rdata for Win64"

This reverts commit r290694. It broke sanitizer tests on Win64. I'll
probably bring this back, but the jump tables will just live in .text
like they do for MSVC.

Modified:
    llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.h
    llvm/trunk/test/CodeGen/X86/win64-jumptable.ll

Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=290714&r1=290713&r2=290714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Thu Dec 29 11:07:10 2016
@@ -156,9 +156,6 @@ public:
   MCSection *getSectionForJumpTable(const Function &F,
                                     const TargetMachine &TM) const override;
 
-  bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
-                                           const Function &F) const override;
-
   /// Emit Obj-C garbage collection and linker options. Only linker option
   /// emission is implemented for COFF.
   void emitModuleFlags(MCStreamer &Streamer,

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=290714&r1=290713&r2=290714&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu Dec 29 11:07:10 2016
@@ -1055,13 +1055,6 @@ MCSection *TargetLoweringObjectFileCOFF:
                                      COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, UniqueID);
 }
 
-bool TargetLoweringObjectFileCOFF::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;
-}
-
 void TargetLoweringObjectFileCOFF::emitModuleFlags(
     MCStreamer &Streamer, ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
     const TargetMachine &TM) const {

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=290714&r1=290713&r2=290714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Dec 29 11:07:10 2016
@@ -1926,20 +1926,10 @@ unsigned X86TargetLowering::getJumpTable
   if (isPositionIndependent() && Subtarget.isPICStyleGOT())
     return MachineJumpTableInfo::EK_Custom32;
 
-  // On Win64, we want to use both label differences and a separate section.
-  if (Subtarget.isTargetWin64())
-    return MachineJumpTableInfo::EK_LabelDifference32;
-
   // Otherwise, use the normal jump table encoding heuristics.
   return TargetLowering::getJumpTableEncoding();
 }
 
-bool X86TargetLowering::isJumpTableRelative() const {
-  if (Subtarget.isTargetWin64())
-    return true;
-  return TargetLowering::isJumpTableRelative();
-}
-
 bool X86TargetLowering::useSoftFloat() const {
   return Subtarget.useSoftFloat();
 }
@@ -1958,19 +1948,11 @@ X86TargetLowering::LowerCustomJumpTableE
 /// Returns relocation base for the given PIC jumptable.
 SDValue X86TargetLowering::getPICJumpTableRelocBase(SDValue Table,
                                                     SelectionDAG &DAG) const {
-  // COFF doesn't have relocations to take the difference between two arbitrary
-  // symbols. The assembler, however, can resolve a fixup between the function
-  // entry and a basic block label, so use the function entry as the base.
-  if (Subtarget.isTargetWin64())
-    return DAG.getGlobalAddress(DAG.getMachineFunction().getFunction(), SDLoc(),
-                                getPointerTy(DAG.getDataLayout()));
-
   if (!Subtarget.is64Bit())
     // This doesn't have SDLoc associated with it, but is not really the
     // same as a Register.
     return DAG.getNode(X86ISD::GlobalBaseReg, SDLoc(),
                        getPointerTy(DAG.getDataLayout()));
-
   return Table;
 }
 
@@ -1979,13 +1961,6 @@ SDValue X86TargetLowering::getPICJumpTab
 const MCExpr *X86TargetLowering::
 getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI,
                              MCContext &Ctx) const {
-  // COFF doesn't have relocations to take the difference between two arbitrary
-  // symbols. The assembler, however, can resolve a fixup between the function
-  // entry and a basic block label, so use the function entry as the base.
-  if (Subtarget.isTargetWin64())
-    return MCSymbolRefExpr::create(
-        getTargetMachine().getSymbol(MF->getFunction()), Ctx);
-
   // X86-64 uses RIP relative addressing based on the jump table label.
   if (Subtarget.isPICStyleRIPRel())
     return TargetLowering::getPICJumpTableRelocBaseExpr(MF, JTI, Ctx);

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=290714&r1=290713&r2=290714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Thu Dec 29 11:07:10 2016
@@ -684,7 +684,6 @@ namespace llvm {
                                const X86Subtarget &STI);
 
     unsigned getJumpTableEncoding() const override;
-    bool isJumpTableRelative() const override;
     bool useSoftFloat() const override;
 
     MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {

Modified: llvm/trunk/test/CodeGen/X86/win64-jumptable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64-jumptable.ll?rev=290714&r1=290713&r2=290714&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/win64-jumptable.ll (original)
+++ llvm/trunk/test/CodeGen/X86/win64-jumptable.ll Thu Dec 29 11:07:10 2016
@@ -1,5 +1,7 @@
-; RUN: llc < %s -relocation-model static | FileCheck %s --check-prefix=CHECK --check-prefix=STATIC
-; RUN: llc < %s -relocation-model pic | FileCheck %s --check-prefix=CHECK --check-prefix=PIC
+; RUN: llc < %s -relocation-model static | FileCheck %s
+
+; FIXME: Remove '-relocation-model static' when it is no longer necessary to
+; trigger the separate .rdata section.
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-windows-msvc19.0.24215"
@@ -39,17 +41,7 @@ declare void @g(i32)
 ; CHECK: .text
 ; CHECK: f:
 ; CHECK: .seh_proc f
-
-; STATIC: movslq .LJTI0_0(,%{{.*}},4), %[[target:[^ ]*]]
-; STATIC: leaq f(%[[target]]), %[[target]]
-; STATIC: jmpq *%[[target]]
-
-; PIC: leaq .LJTI0_0(%rip), %[[jt:[^ ]*]]
-; PIC: movslq (%[[jt]],%{{.*}},4), %[[offset:[^ ]*]]
-; PIC: leaq f(%rip), %[[base:[^ ]*]]
-; PIC: addq %[[offset]], %[[base]]
-; PIC: jmpq *%[[base]]
-
+; CHECK: jmpq    *.LJTI0_0
 ; CHECK: .LBB0_{{.*}}: # %sw.bb
 ; CHECK: .LBB0_{{.*}}: # %sw.bb1
 ; CHECK: .LBB0_{{.*}}: # %sw.bb2
@@ -57,10 +49,10 @@ declare void @g(i32)
 ; CHECK: callq g
 ; CHECK: jmp g # TAILCALL
 ; CHECK: .section        .rdata,"dr"
-; CHECK: .long .LBB0_{{.*}}-f
-; CHECK: .long .LBB0_{{.*}}-f
-; CHECK: .long .LBB0_{{.*}}-f
-; CHECK: .long .LBB0_{{.*}}-f
+; CHECK: .quad .LBB0_
+; CHECK: .quad .LBB0_
+; CHECK: .quad .LBB0_
+; CHECK: .quad .LBB0_
 ; CHECK: .seh_handlerdata
 
 ; It's important that we switch back to .text here, not .rdata.




More information about the llvm-commits mailing list