[llvm-branch-commits] [llvm-branch] r81648 - in /llvm/branches/release_26/lib/Target/ARM: ARMCodeEmitter.cpp ARMJITInfo.cpp

Tanya Lattner tonic at nondot.org
Sat Sep 12 15:50:39 PDT 2009


Author: tbrethou
Date: Sat Sep 12 17:50:39 2009
New Revision: 81648

URL: http://llvm.org/viewvc/llvm-project?rev=81648&view=rev
Log:
Merge 81422 from mainline.
Proper support of non-lazy indirect symbols.


Modified:
    llvm/branches/release_26/lib/Target/ARM/ARMCodeEmitter.cpp
    llvm/branches/release_26/lib/Target/ARM/ARMJITInfo.cpp

Modified: llvm/branches/release_26/lib/Target/ARM/ARMCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_26/lib/Target/ARM/ARMCodeEmitter.cpp?rev=81648&r1=81647&r2=81648&view=diff

==============================================================================
--- llvm/branches/release_26/lib/Target/ARM/ARMCodeEmitter.cpp (original)
+++ llvm/branches/release_26/lib/Target/ARM/ARMCodeEmitter.cpp Sat Sep 12 17:50:39 2009
@@ -60,6 +60,7 @@
     ARMJITInfo                *JTI;
     const ARMInstrInfo        *II;
     const TargetData          *TD;
+    const ARMSubtarget        *Subtarget;
     TargetMachine             &TM;
     CodeEmitter               &MCE;
     const std::vector<MachineConstantPoolEntry> *MCPEs;
@@ -163,7 +164,7 @@
     /// Routines that handle operands which add machine relocations which are
     /// fixed up by the relocation stage.
     void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
-                           bool NeedStub, intptr_t ACPV = 0);
+                           bool NeedStub,  bool Indirect, intptr_t ACPV = 0);
     void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
     void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
     void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
@@ -195,9 +196,10 @@
   assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
           MF.getTarget().getRelocationModel() != Reloc::Static) &&
          "JIT relocation model must be set to static or default!");
+  JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
   II = ((ARMTargetMachine&)MF.getTarget()).getInstrInfo();
   TD = ((ARMTargetMachine&)MF.getTarget()).getTargetData();
-  JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
+  Subtarget = &TM.getSubtarget<ARMSubtarget>();
   MCPEs = &MF.getConstantPool()->getConstants();
   MJTEs = &MF.getJumpTableInfo()->getJumpTables();
   IsPIC = TM.getRelocationModel() == Reloc::PIC_;
@@ -244,7 +246,7 @@
   else if (MO.isImm())
     return static_cast<unsigned>(MO.getImm());
   else if (MO.isGlobal())
-    emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true);
+    emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true, false);
   else if (MO.isSymbol())
     emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_branch);
   else if (MO.isCPI()) {
@@ -270,9 +272,14 @@
 ///
 template<class CodeEmitter>
 void Emitter<CodeEmitter>::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
-                                             bool NeedStub, intptr_t ACPV) {
-  MCE.addRelocation(MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
-                                             GV, ACPV, NeedStub));
+                                             bool NeedStub, bool Indirect,
+                                             intptr_t ACPV) {
+  MachineRelocation MR = Indirect
+    ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
+                                           GV, ACPV, NeedStub)
+    : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
+                               GV, ACPV, NeedStub);
+  MCE.addRelocation(MR);
 }
 
 /// emitExternalSymbolAddress - Arrange for the address of an external symbol to
@@ -423,8 +430,11 @@
 
     GlobalValue *GV = ACPV->getGV();
     if (GV) {
+      Reloc::Model RelocM = TM.getRelocationModel();
       emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
-                        isa<Function>(GV), (intptr_t)ACPV);
+                        isa<Function>(GV),
+                        Subtarget->GVIsIndirectSymbol(GV, RelocM),
+                        (intptr_t)ACPV);
      } else  {
       emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
     }
@@ -443,7 +453,7 @@
       });
 
     if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
-      emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV));
+      emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV), false);
       emitWordLE(0);
     } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
       uint32_t Val = *(uint32_t*)CI->getValue().getRawData();

Modified: llvm/branches/release_26/lib/Target/ARM/ARMJITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_26/lib/Target/ARM/ARMJITInfo.cpp?rev=81648&r1=81647&r2=81648&view=diff

==============================================================================
--- llvm/branches/release_26/lib/Target/ARM/ARMJITInfo.cpp (original)
+++ llvm/branches/release_26/lib/Target/ARM/ARMJITInfo.cpp Sat Sep 12 17:50:39 2009
@@ -147,6 +147,9 @@
     llvm_unreachable("ERROR: Unable to mark indirect symbol writable");
   }
   JCE.emitWordLE((intptr_t)Ptr);
+  if (!sys::Memory::setRangeExecutable((void*)Addr, 4)) {
+    llvm_unreachable("ERROR: Unable to mark indirect symbol executable");
+  }
   void *PtrAddr = JCE.finishGVStub(GV);
   addIndirectSymAddr(Ptr, (intptr_t)PtrAddr);
   return PtrAddr;





More information about the llvm-branch-commits mailing list