aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPC32ISelSimple.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-09 22:05:17 +0000
committerChris Lattner <sabre@nondot.org>2005-04-09 22:05:17 +0000
commit9184bfbbf47558da3e23d1b3483b7bac684925c1 (patch)
tree1aa512f426f75483b239f60d1a5232fcf52864fa /lib/Target/PowerPC/PPC32ISelSimple.cpp
parentd0abb7a2ec61c61e35d4c8da1708dd39ab4d1d48 (diff)
Fix CodeGen/Generic/2005-05-09-GlobalInPHI.ll, which was reduced from 254.gap.
This caused the "use before a def" assertion on some programs. With this patch, 254.gap now passes with the PPC backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPC32ISelSimple.cpp')
-rw-r--r--lib/Target/PowerPC/PPC32ISelSimple.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp
index 3d84865b82..d7e131daea 100644
--- a/lib/Target/PowerPC/PPC32ISelSimple.cpp
+++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp
@@ -871,6 +871,16 @@ void PPC32ISel::LoadArgumentsToVirtualRegs(Function &Fn) {
void PPC32ISel::SelectPHINodes() {
const TargetInstrInfo &TII = *TM.getInstrInfo();
const Function &LF = *F->getFunction(); // The LLVM function...
+
+ MachineBasicBlock::iterator MFLRIt = F->begin()->begin();
+ if (GlobalBaseInitialized) {
+ // If we emitted a MFLR for the global base reg, get an iterator to an
+ // instruction after it.
+ while (MFLRIt->getOpcode() != PPC::MFLR)
+ ++MFLRIt;
+ ++MFLRIt; // step one MI past it.
+ }
+
for (Function::const_iterator I = LF.begin(), E = LF.end(); I != E; ++I) {
const BasicBlock *BB = I;
MachineBasicBlock &MBB = *MBBMap[I];
@@ -938,6 +948,12 @@ void PPC32ISel::SelectPHINodes() {
while (PI != PredMBB->end() && PI->getOpcode() == PPC::PHI)
++PI;
+ // If this is the entry block, and if the entry block contains a
+ // MFLR instruction, emit this operation after it. This is needed
+ // because global addresses use it.
+ if (PredMBB == F->begin())
+ PI = MFLRIt;
+
ValReg = getReg(Val, PredMBB, PI);
}