- Added option -relocation-model to set relocation model. Valid values include static...
authorEvan Cheng <evan.cheng@apple.com>
Wed, 22 Feb 2006 20:19:42 +0000 (20:19 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 22 Feb 2006 20:19:42 +0000 (20:19 +0000)
dynamic-no-pic, and default.
PPC and x86 default is dynamic-no-pic for Darwin, pic for others.
- Removed options -enable-pic and -ppc-static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26315 91177308-0d34-0410-b5e6-96231b3b80d8

14 files changed:
include/llvm/Target/TargetMachine.h
include/llvm/Target/TargetOptions.h
lib/Target/PowerPC/PPC.h
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCCodeEmitter.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/TargetMachine.cpp
lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86CodeEmitter.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86IntelAsmPrinter.cpp
lib/Target/X86/X86TargetMachine.cpp

index d13a4ed78df89688662f2e3e279b49a30f288509..5a58951a75a6e774ee459d07657c9391530b60de 100644 (file)
@@ -34,6 +34,16 @@ class PassManager;
 class Pass;
 class IntrinsicLowering;
 
+// Relocation model types.
+namespace Reloc {
+  enum Model {
+    Default,
+    Static,
+    PIC,
+    DynamicNoPIC
+  };
+}
+
 //===----------------------------------------------------------------------===//
 ///
 /// TargetMachine - Primary interface to the complete machine description for
@@ -135,6 +145,13 @@ public:
   virtual const TargetSchedInfo        *getSchedInfo() const { return 0; }
   virtual const SparcV9RegInfo         *getRegInfo()   const { return 0; }
 
+  /// getRelocationModel - Returns the code generation relocation model. The
+  /// choices are static, PIC, and dynamic-no-pic, and target default.
+  static Reloc::Model getRelocationModel();
+
+  /// setRelocationModel - Sets the code generation relocation model.
+  static void setRelocationModel(Reloc::Model Model);
+
   /// CodeGenFileType - These enums are meant to be passed into
   /// addPassesToEmitFile to indicate what type of file to emit.
   enum CodeGenFileType {
index 31fdeb8fed2686640b415f68f779b173e27897d8..e208eba6418c76ad370886b1bdca5e58d89657c6 100644 (file)
@@ -40,12 +40,6 @@ namespace llvm {
   /// produce results that are "less precise" than IEEE allows.  This includes
   /// use of X86 instructions like FSIN and FCOS instead of libcalls.
   extern bool UnsafeFPMath;
-
-  /// PICEnabled - This flag is enabled when the -enable-pic flag is specified
-  /// on the command line. When this flag is on, the code generator produces
-  /// position independant code.
-  extern bool PICEnabled;
-
 } // End llvm namespace
 
 #endif
index 1146cdf327adff0384e931817948f1662b368428..a12dfdfb112b9c06300e1773fabb94378c1df9f1 100644 (file)
@@ -31,7 +31,6 @@ FunctionPass *createPPCISelDag(TargetMachine &TM);
 FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM);
 FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM);
 
-extern bool PPCGenerateStaticCode;
 extern PPCTargetEnum PPCTarget;
 } // end namespace llvm;
 
index bc19f1659d9628c35201dc0c1e1fbcb21eaa80f1..714a36d1e7df339f2681298ddc7eb39374178c5c 100644 (file)
@@ -132,7 +132,7 @@ namespace {
     }
     void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
       const MachineOperand &MO = MI->getOperand(OpNo);
-      if (!PPCGenerateStaticCode) {
+      if (TM.getRelocationModel() != Reloc::Static) {
         if (MO.getType() == MachineOperand::MO_GlobalAddress) {
           GlobalValue *GV = MO.getGlobal();
           if (((GV->isExternal() || GV->hasWeakLinkage() ||
@@ -167,7 +167,7 @@ namespace {
       } else {
         O << "ha16(";
         printOp(MI->getOperand(OpNo));
-        if (PICEnabled)
+        if (TM.getRelocationModel() == Reloc::PIC)
           O << "-\"L" << getFunctionNumber() << "$pb\")";
         else
           O << ')';
@@ -179,7 +179,7 @@ namespace {
       } else {
         O << "lo16(";
         printOp(MI->getOperand(OpNo));
-        if (PICEnabled)
+        if (TM.getRelocationModel() == Reloc::PIC)
           O << "-\"L" << getFunctionNumber() << "$pb\")";
         else
           O << ')';
@@ -362,7 +362,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
     return;
   case MachineOperand::MO_ExternalSymbol:
     // Computing the address of an external symbol, not calling it.
-    if (!PPCGenerateStaticCode) {
+    if (TM.getRelocationModel() != Reloc::Static) {
       std::string Name(GlobalPrefix); Name += MO.getSymbolName();
       GVStubs.insert(Name);
       O << "L" << Name << "$non_lazy_ptr";
@@ -377,7 +377,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
     int offset = MO.getOffset();
 
     // External or weakly linked global variables need non-lazily-resolved stubs
-    if (!PPCGenerateStaticCode) {
+    if (TM.getRelocationModel() != Reloc::Static) {
       if (((GV->isExternal() || GV->hasWeakLinkage() ||
             GV->hasLinkOnceLinkage()))) {
         GVStubs.insert(Name);
@@ -585,7 +585,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
   }
 
   // Output stubs for dynamically-linked functions
-  if (PICEnabled) {
+  if (TM.getRelocationModel() == Reloc::PIC) {
     for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
          i != e; ++i) {
       SwitchSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
index 5103f27275367602d0e081e987b9c07e20dfec00..d315a2d62b8dd29a2b62738207c97872aaa238b3 100644 (file)
@@ -86,6 +86,9 @@ bool PPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
 }
 
 bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
+  assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
+          MF.getTarget().getRelocationModel() != Reloc::Static) &&
+         "JIT relocation model must be set to static or default!");
   MCE.startFunction(MF);
   MCE.emitConstantPool(MF.getConstantPool());
   for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
@@ -118,7 +121,6 @@ bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
 }
 
 void PPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
-  assert(!PICEnabled && "CodeEmitter does not support PIC!");
   BBLocations[&MBB] = MCE.getCurrentPCValue();
   for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
     MachineInstr &MI = *I;
index 003d16c26b11605552704cd88d009a16f4c23bbe..154fe177ba1b0ccf51b518c59cb3bac92ee26d14 100644 (file)
@@ -396,7 +396,7 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i32, CP->getAlignment());
     SDOperand Zero = DAG.getConstant(0, MVT::i32);
     
-    if (PPCGenerateStaticCode) {
+    if (getTargetMachine().getRelocationModel() == Reloc::Static) {
       // Generate non-pic code that has direct accesses to the constant pool.
       // The address of the global is just (hi(&g)+lo(&g)).
       SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
@@ -407,7 +407,7 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     // Only lower ConstantPool on Darwin.
     if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
     SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
-    if (PICEnabled) {
+    if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
       // With PIC, the first instruction is actually "GR+hi(&G)".
       Hi = DAG.getNode(ISD::ADD, MVT::i32,
                        DAG.getNode(PPCISD::GlobalBaseReg, MVT::i32), Hi);
@@ -423,7 +423,7 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32, GSDN->getOffset());
     SDOperand Zero = DAG.getConstant(0, MVT::i32);
 
-    if (PPCGenerateStaticCode) {
+    if (getTargetMachine().getRelocationModel() == Reloc::Static) {
       // Generate non-pic code that has direct accesses to globals.
       // The address of the global is just (hi(&g)+lo(&g)).
       SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
@@ -435,7 +435,7 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
     
     SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
-    if (PICEnabled) {
+    if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
       // With PIC, the first instruction is actually "GR+hi(&G)".
       Hi = DAG.getNode(ISD::ADD, MVT::i32,
                        DAG.getNode(PPCISD::GlobalBaseReg, MVT::i32), Hi);
index c7a34280ea7e46d040c4eda90ae4d6738e218227..606dfc09799f698a704c399ceee5c3615dc3449f 100644 (file)
@@ -19,7 +19,6 @@
 
 using namespace llvm;
 PPCTargetEnum llvm::PPCTarget = TargetDefault;
-bool llvm::PPCGenerateStaticCode = false;
 
 namespace llvm {
   cl::opt<PPCTargetEnum, true>
@@ -29,12 +28,7 @@ namespace llvm {
                           clEnumValN(TargetDarwin,"darwin",
                                      "  Enable Darwin codegen"),
                           clEnumValEnd),
-               cl::location(PPCTarget), cl::init(TargetDefault));
-  
-  cl::opt<bool, true>
-  PPCStaticCode("ppc-static",
-                cl::desc("PowerPC: generate completely non-pic code"),
-                cl::location(PPCGenerateStaticCode));
+               cl::location(PPCTarget), cl::init(TargetDefault));  
 } 
  
 #if defined(__APPLE__)
index a58926ff7e847f7e624d3db81f85ff337a7624bf..9b5701b65e959e592b6db97bd94132985fb723b8 100644 (file)
@@ -67,6 +67,11 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, IntrinsicLowering *IL,
     if (Subtarget.isAIX()) PPCTarget = TargetAIX;
     if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
   }
+  if (getRelocationModel() == Reloc::Default)
+    if (Subtarget.isDarwin())
+      setRelocationModel(Reloc::DynamicNoPIC);
+    else
+      setRelocationModel(Reloc::PIC);
 }
 
 /// addPassesToEmitFile - Add passes to the specified pass manager to implement
@@ -129,8 +134,8 @@ bool PPCTargetMachine::addPassesToEmitFile(PassManager &PM,
 }
 
 void PPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
-  // The JIT does not support or need PIC.
-  PICEnabled = false;
+  // The JIT should use static relocation model.
+  TM.setRelocationModel(Reloc::Static);
 
   // Run loop strength reduction before anything else.
   PM.add(createLoopStrengthReducePass());
index 82759e8280c81aaa59bc6c787f10c0b3cb2fed39..a2a4200b06752b48841c5466b4e2f4b053485f39 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetOptions.h"
 #include "llvm/Type.h"
 #include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/Support/CommandLine.h"
@@ -26,7 +27,7 @@ namespace llvm {
   bool NoFramePointerElim;
   bool NoExcessFPPrecision;
   bool UnsafeFPMath;
-  bool PICEnabled;
+  Reloc::Model RelocationModel;
 };
 namespace {
   cl::opt<bool, true> PrintCode("print-machineinstrs",
@@ -48,11 +49,22 @@ namespace {
                cl::desc("Enable optimizations that may decrease FP precision"),
                cl::location(UnsafeFPMath),
                cl::init(false));
-  cl::opt<bool, true>
-  EnablePIC("enable-pic",
-               cl::desc("Enable generation of position independant code"),
-               cl::location(PICEnabled),
-               cl::init(false));
+  cl::opt<llvm::Reloc::Model, true>
+  DefRelocationModel(
+    "relocation-model",
+    cl::desc("Choose relocation model"),
+    cl::location(RelocationModel),
+    cl::init(Reloc::Default),
+    cl::values(
+      clEnumValN(Reloc::Default, "default",
+                 "Target default relocation model"),
+      clEnumValN(Reloc::Static, "static",
+                 "Non-relocatable code"),
+      clEnumValN(Reloc::PIC, "pic",
+                 "Fully relocatable, position independent code"),
+      clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
+                 "Relocatable external references, non-relocatable code"),
+      clEnumValEnd));
 };
 
 //---------------------------------------------------------------------------
@@ -87,3 +99,13 @@ TargetMachine::~TargetMachine() {
   delete IL;
 }
 
+/// getRelocationModel - Returns the code generation relocation model. The
+/// choices are static, PIC, and dynamic-no-pic, and target default.
+Reloc::Model TargetMachine::getRelocationModel() {
+  return RelocationModel;
+}
+
+/// setRelocationModel - Sets the code generation relocation model.
+void TargetMachine::setRelocationModel(Reloc::Model Model) {
+  RelocationModel = Model;
+}
index 9b43873f290da7c420f1a5191f7b17c9770f3bd8..f1774fd8946c9f0cc9f61a7a43705c6785ec2fc2 100755 (executable)
@@ -119,7 +119,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp && !isCallOp) O << '$';
     // Darwin block shameless ripped from PPCAsmPrinter.cpp
-    if (forDarwin) {
+    if (forDarwin && TM.getRelocationModel() != Reloc::Static) {
       GlobalValue *GV = MO.getGlobal();
       std::string Name = Mang->getValueName(GV);
       // Link-once, External, or Weakly-linked global variables need
@@ -133,7 +133,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
         } else {
           GVStubs.insert(Name);
           O << "L" << Name << "$non_lazy_ptr";
-          if (PICEnabled)
+          if (TM.getRelocationModel() == Reloc::PIC)
             O << "-\"L" << getFunctionNumber() << "$pb\"";
         }
       } else {
@@ -150,14 +150,14 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
   }
   case MachineOperand::MO_ExternalSymbol: {
     bool isCallOp = Modifier && !strcmp(Modifier, "call");
-    bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
-    if (isCallOp && forDarwin) {
-      std::string Name(GlobalPrefix); Name += MO.getSymbolName();
+    if (isCallOp && forDarwin && TM.getRelocationModel() != Reloc::Static) {
+      std::string Name(GlobalPrefix);
+      Name += MO.getSymbolName();
       FnStubs.insert(Name);
       O << "L" << Name << "$stub";
       return;
     }
-    if (!isMemOp && !isCallOp) O << '$';
+    if (!isCallOp) O << '$';
     O << GlobalPrefix << MO.getSymbolName();
     return;
   }
@@ -198,7 +198,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   } else if (BaseReg.isConstantPoolIndex()) {
     O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
       << BaseReg.getConstantPoolIndex();
-    if (forDarwin && PICEnabled)
+    if (forDarwin && TM.getRelocationModel() == Reloc::PIC)
       O << "-\"L" << getFunctionNumber() << "$pb\"";
     if (DispSpec.getImmedValue())
       O << "+" << DispSpec.getImmedValue();
index 0c0ed538ab2023bca8c13389e7ca06a33e7e0707..772f1abc204861e1d5ec6b85ebacceab0dd1439b 100644 (file)
@@ -77,6 +77,9 @@ FunctionPass *llvm::createX86CodeEmitterPass(MachineCodeEmitter &MCE) {
 }
 
 bool Emitter::runOnMachineFunction(MachineFunction &MF) {
+  assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
+          MF.getTarget().getRelocationModel() != Reloc::Static) &&
+         "JIT relocation model must be set to static or default!");
   II = ((X86TargetMachine&)MF.getTarget()).getInstrInfo();
 
   MCE.startFunction(MF);
@@ -97,7 +100,6 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) {
 }
 
 void Emitter::emitBasicBlock(const MachineBasicBlock &MBB) {
-  assert(!PICEnabled && "CodeEmitter does not support PIC!");
   if (uint64_t Addr = MCE.getCurrentPCValue())
     BasicBlockAddrs[&MBB] = Addr;
 
index 77fc52bc457ad38f71bcd0cbebcfe556bd6f19a5..105e6cebcb687f80e975987ce8587c63c8d1213f 100644 (file)
@@ -1836,7 +1836,7 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     if (getTargetMachine().
         getSubtarget<X86Subtarget>().isTargetDarwin()) {
       // With PIC, the address is actually $g + Offset.
-      if (PICEnabled)
+      if (getTargetMachine().getRelocationModel() == Reloc::PIC)
         Result = DAG.getNode(ISD::ADD, getPointerTy(),
                 DAG.getNode(X86ISD::GlobalBaseReg, getPointerTy()), Result);    
     }
@@ -1851,7 +1851,7 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
       GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
       SDOperand Addr = DAG.getTargetGlobalAddress(GV, getPointerTy());
       // With PIC, the address is actually $g + Offset.
-      if (PICEnabled)
+      if (getTargetMachine().getRelocationModel() == Reloc::PIC)
         Addr = DAG.getNode(ISD::ADD, getPointerTy(),
                       DAG.getNode(X86ISD::GlobalBaseReg, getPointerTy()), Addr);
 
@@ -1859,8 +1859,9 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
       // the value at address GV, not the value of GV itself.  This means that
       // the GlobalAddress must be in the base or index register of the address,
       // not the GV offset field.
-      if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
-          (GV->isExternal() && !GV->hasNotBeenReadFromBytecode()))
+      if (getTargetMachine().getRelocationModel() != Reloc::Static &&
+          (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
+           (GV->isExternal() && !GV->hasNotBeenReadFromBytecode())))
         Result = DAG.getLoad(MVT::i32, DAG.getEntryNode(),
                              Addr, DAG.getSrcValue(NULL));
     }
index 90fe3ac6492485b0bfab9fb02348820fbc3b7908..1a5aba16608497dca8e70847f66da221189ccb5f 100755 (executable)
@@ -113,7 +113,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
     bool isCallOp = Modifier && !strcmp(Modifier, "call");
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp && !isCallOp) O << "OFFSET ";
-    if (forDarwin) {
+    if (forDarwin && TM.getRelocationModel() != Reloc::Static) {
       GlobalValue *GV = MO.getGlobal();
       std::string Name = Mang->getValueName(GV);
       if (!isMemOp && !isCallOp) O << '$';
@@ -128,7 +128,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
         } else {
           GVStubs.insert(Name);
           O << "L" << Name << "$non_lazy_ptr";
-          if (PICEnabled)
+          if (TM.getRelocationModel() == Reloc::PIC)
             O << "-\"L" << getFunctionNumber() << "$pb\"";
         }
       } else {
@@ -145,13 +145,14 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
   }
   case MachineOperand::MO_ExternalSymbol: {
     bool isCallOp = Modifier && !strcmp(Modifier, "call");
-    bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
-    if (isCallOp && forDarwin) {
-      std::string Name(GlobalPrefix); Name += MO.getSymbolName();
+    if (isCallOp && forDarwin && TM.getRelocationModel() != Reloc::Static) {
+      std::string Name(GlobalPrefix);
+      Name += MO.getSymbolName();
       FnStubs.insert(Name);
       O << "L" << Name << "$stub";
       return;
     }
+    if (!isCallOp) O << "OFFSET ";
     O << GlobalPrefix << MO.getSymbolName();
     return;
   }
@@ -177,7 +178,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   } else if (BaseReg.isConstantPoolIndex()) {
     O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
       << BaseReg.getConstantPoolIndex();
-    if (forDarwin && PICEnabled)
+    if (forDarwin && TM.getRelocationModel() == Reloc::PIC)
       O << "-\"L" << getFunctionNumber() << "$pb\"";
 
     if (IndexReg.getReg()) {
index f24e1b026a96c721e31d801644d85b9f8216b901..8adce3115dedff5eda1796ea993f78730eecf158 100644 (file)
@@ -76,6 +76,11 @@ X86TargetMachine::X86TargetMachine(const Module &M,
     FrameInfo(TargetFrameInfo::StackGrowsDown,
               Subtarget.getStackAlignment(), -4),
     JITInfo(*this) {
+  if (getRelocationModel() == Reloc::Default)
+    if (Subtarget.isTargetDarwin())
+      setRelocationModel(Reloc::DynamicNoPIC);
+    else
+      setRelocationModel(Reloc::PIC);
 }
 
 
@@ -149,8 +154,8 @@ bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
 /// not supported for this target.
 ///
 void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
-  // The JIT does not support or need PIC.
-  PICEnabled = false;
+  // The JIT should use static relocation model.
+  TM.setRelocationModel(Reloc::Static);
 
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());