summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-09-24 05:22:38 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-09-24 05:22:38 +0000
commit2ae5b87996dca039d0721f1c463835f726979030 (patch)
tree552c9be1a82d1d2e128e81b71886124b1ce1aaa7
parentb156afb79106ad53c61408d5037feb7d8128359a (diff)
downloadexternal_llvm-2ae5b87996dca039d0721f1c463835f726979030.zip
external_llvm-2ae5b87996dca039d0721f1c463835f726979030.tar.gz
external_llvm-2ae5b87996dca039d0721f1c463835f726979030.tar.bz2
PIC jump table entries are always 32-bit. This fixes PIC jump table support on X86-64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30590 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 6515c99..cf26eb2 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -857,18 +857,17 @@ void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) {
MVT::ValueType PTy = TLI.getPointerTy();
assert((PTy == MVT::i32 || PTy == MVT::i64) &&
"Jump table entries are 32-bit values");
+ bool isPIC = TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_;
// PIC jump table entries are 32-bit values.
- unsigned EntrySize =
- (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_)
- ? 4 : MVT::getSizeInBits(PTy)/8;
+ unsigned EntrySize = isPIC ? 4 : MVT::getSizeInBits(PTy)/8;
SDOperand Copy = DAG.getCopyFromReg(getRoot(), JT.Reg, PTy);
SDOperand IDX = DAG.getNode(ISD::MUL, PTy, Copy,
DAG.getConstant(EntrySize, PTy));
SDOperand TAB = DAG.getJumpTable(JT.JTI,PTy);
SDOperand ADD = DAG.getNode(ISD::ADD, PTy, IDX, TAB);
- SDOperand LD = DAG.getLoad(PTy, Copy.getValue(1), ADD,
+ SDOperand LD = DAG.getLoad(isPIC ? MVT::i32 : PTy, Copy.getValue(1), ADD,
DAG.getSrcValue(0));
- if (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ if (isPIC) {
ADD = DAG.getNode(ISD::ADD, PTy,
((PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD), TAB);
DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), ADD));