Tell ARMJITInfo if codegen relocation is PIC. It changes how function stubs are gener...
authorEvan Cheng <evan.cheng@apple.com>
Sat, 8 Nov 2008 07:38:22 +0000 (07:38 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 8 Nov 2008 07:38:22 +0000 (07:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58896 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMCodeEmitter.cpp
lib/Target/ARM/ARMJITInfo.h
lib/Target/ARM/ARMTargetMachine.cpp

index 1fefc0eba854368922b82b71fc755ff847ca07fb..92d8713bca7f2c52b8486b0c37ee9708465ec04c 100644 (file)
@@ -167,7 +167,7 @@ bool ARMCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
   MCPEs = &MF.getConstantPool()->getConstants();
   MJTEs = &MF.getJumpTableInfo()->getJumpTables();
   IsPIC = TM.getRelocationModel() == Reloc::PIC_;
-  JTI->Initialize(MF);
+  JTI->Initialize(MF, IsPIC);
 
   do {
     DOUT << "JITTing function '" << MF.getFunction()->getName() << "'\n";
index 91d51b4b5b7ff52b65456fe7262dd8d15569b7cc..fe1ea1029e2aee3bfde8ef5c7537274baa2d02de 100644 (file)
@@ -26,8 +26,6 @@ namespace llvm {
   class ARMTargetMachine;
 
   class ARMJITInfo : public TargetJITInfo {
-    ARMTargetMachine &TM;
-
     // ConstPoolId2AddrMap - A map from constant pool ids to the corresponding
     // CONSTPOOL_ENTRY addresses.
     SmallVector<intptr_t, 16> ConstPoolId2AddrMap;
@@ -39,8 +37,12 @@ namespace llvm {
     // PCLabelMap - A map from PC labels to addresses.
     DenseMap<unsigned, intptr_t> PCLabelMap;
 
+    // IsPIC - True if the relocation model is PIC. This is used to determine
+    // how to codegen function stubs.
+    bool IsPIC;
+
   public:
-    explicit ARMJITInfo(ARMTargetMachine &tm) : TM(tm) { useGOT = false; }
+    explicit ARMJITInfo() : IsPIC(false) { useGOT = false; }
 
     /// replaceMachineCodeForFunction - Make it so that calling the function
     /// whose machine code is at OLD turns into a call to NEW, perhaps by
@@ -89,12 +91,15 @@ namespace llvm {
 #endif
     }
 
-    /// Initialize - Initialize internal stage. Get the list of constant pool
-    /// Resize constant pool ids to CONSTPOOL_ENTRY addresses map.
-    void Initialize(const MachineFunction &MF) {
+    /// Initialize - Initialize internal stage for the function being JITted.
+    /// Resize constant pool ids to CONSTPOOL_ENTRY addresses map; resize
+    /// jump table ids to jump table bases map; remember if codegen relocation
+    /// model is PIC.
+    void Initialize(const MachineFunction &MF, bool isPIC) {
       const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
       ConstPoolId2AddrMap.resize(AFI->getNumConstPoolEntries());
       JumpTableId2AddrMap.resize(AFI->getNumJumpTables());
+      IsPIC = isPIC;
     }
 
     /// getConstantPoolEntryAddr - The ARM target puts all constant
index 4ffd7798112264e9c06d0b8ef752c41989367100..b9c9c4860056e6c16df4eee1bb4203fe637a7f5d 100644 (file)
@@ -84,7 +84,7 @@ ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS,
            std::string("e-p:32:32-f64:64:64-i64:64:64"))),
     InstrInfo(Subtarget),
     FrameInfo(Subtarget),
-    JITInfo(*this),
+    JITInfo(),
     TLInfo(*this) {
   DefRelocModel = getRelocationModel();
 }