Treat external variables similarly to those with weak linkage: load indirect.
authorMisha Brukman <brukman+llvm@gmail.com>
Tue, 20 Jul 2004 20:43:05 +0000 (20:43 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Tue, 20 Jul 2004 20:43:05 +0000 (20:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15047 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPC32ISelSimple.cpp
lib/Target/PowerPC/PowerPCISelSimple.cpp

index 8605380e17dcfdc421bcea885925182eb1d15e8a..8c212dcf14a3b94ceadb3b21d437ea6c86d423ea 100644 (file)
@@ -524,9 +524,8 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
     // GV is located at PC + distance
     unsigned CurPC = makeAnotherReg(Type::IntTy);
     unsigned TmpReg = makeAnotherReg(GV->getType());
-    unsigned Opcode = GV->hasWeakLinkage() ? 
-      PPC32::LOADLoIndirect : 
-      PPC32::LOADLoDirect;
+    unsigned Opcode = (GV->hasWeakLinkage() || GV->isExternal()) ? 
+      PPC32::LOADLoIndirect : PPC32::LOADLoDirect;
       
     // Move PC to destination reg
     BuildMI(*MBB, IP, PPC32::MovePCtoLR, 0, CurPC);
@@ -2481,7 +2480,8 @@ void ISel::emitCastOperation(MachineBasicBlock *MBB,
       unsigned SrcReg2 = makeAnotherReg(Type::IntTy);
       BuildMI(*MBB, IP, PPC32::OR, 2, SrcReg2).addReg(SrcReg).addReg(SrcReg+1);
       BuildMI(*MBB, IP, PPC32::ADDIC, 2, TmpReg).addReg(SrcReg2).addImm(-1);
-      BuildMI(*MBB, IP, PPC32::SUBFE, 2, DestReg).addReg(TmpReg).addReg(SrcReg2);
+      BuildMI(*MBB, IP, PPC32::SUBFE, 2, DestReg).addReg(TmpReg)
+        .addReg(SrcReg2);
       break;
     }
     case cFP32:
index 8605380e17dcfdc421bcea885925182eb1d15e8a..8c212dcf14a3b94ceadb3b21d437ea6c86d423ea 100644 (file)
@@ -524,9 +524,8 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
     // GV is located at PC + distance
     unsigned CurPC = makeAnotherReg(Type::IntTy);
     unsigned TmpReg = makeAnotherReg(GV->getType());
-    unsigned Opcode = GV->hasWeakLinkage() ? 
-      PPC32::LOADLoIndirect : 
-      PPC32::LOADLoDirect;
+    unsigned Opcode = (GV->hasWeakLinkage() || GV->isExternal()) ? 
+      PPC32::LOADLoIndirect : PPC32::LOADLoDirect;
       
     // Move PC to destination reg
     BuildMI(*MBB, IP, PPC32::MovePCtoLR, 0, CurPC);
@@ -2481,7 +2480,8 @@ void ISel::emitCastOperation(MachineBasicBlock *MBB,
       unsigned SrcReg2 = makeAnotherReg(Type::IntTy);
       BuildMI(*MBB, IP, PPC32::OR, 2, SrcReg2).addReg(SrcReg).addReg(SrcReg+1);
       BuildMI(*MBB, IP, PPC32::ADDIC, 2, TmpReg).addReg(SrcReg2).addImm(-1);
-      BuildMI(*MBB, IP, PPC32::SUBFE, 2, DestReg).addReg(TmpReg).addReg(SrcReg2);
+      BuildMI(*MBB, IP, PPC32::SUBFE, 2, DestReg).addReg(TmpReg)
+        .addReg(SrcReg2);
       break;
     }
     case cFP32: