Calls do not need a MovPCtoLR instruction
authorChris Lattner <sabre@nondot.org>
Wed, 24 Nov 2004 02:00:06 +0000 (02:00 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 24 Nov 2004 02:00:06 +0000 (02:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18197 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCCodeEmitter.cpp

index 14dbcff2dbfec7569b9144f8d0dbdde7deceaca8..68f9cccc4add2f2715bb2a56865371b400ae1eeb 100644 (file)
@@ -190,19 +190,22 @@ int PPC32CodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
     rv = MO.getImmedValue();
   } else if (MO.isGlobalAddress()) {
     unsigned Reloc = 0;
+    int Offset = 0;
     if (MI.getOpcode() == PPC::CALLpcrel)
       Reloc = PPC::reloc_pcrel_bx;
     else if (MI.getOpcode() == PPC::LOADHiAddr) {
+      assert(MovePCtoLROffset && "MovePCtoLR not seen yet?");
       Reloc = PPC::reloc_absolute_loadhi;
+      Offset = -((intptr_t)MovePCtoLROffset+4);
     } else if (MI.getOpcode() == PPC::LA) {
+      assert(MovePCtoLROffset && "MovePCtoLR not seen yet?");
       Reloc = PPC::reloc_absolute_la;
+      Offset = -((intptr_t)MovePCtoLROffset+4);
     } else {
       assert(0 && "Unknown instruction for relocation!");
     }
-    assert(MovePCtoLROffset && "MovePCtoLR not seen yet?");
     MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
-                                        Reloc, MO.getGlobal(),
-                                        -((intptr_t)MovePCtoLROffset+4)));
+                                        Reloc, MO.getGlobal(), Offset));
   } else if (MO.isMachineBasicBlock()) {
     const BasicBlock *BB = MO.getMachineBasicBlock()->getBasicBlock();
     unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();