[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Apr 9 15:05:30 PDT 2005
Changes in directory llvm/lib/Target/PowerPC:
PPC32ISelSimple.cpp updated: 1.136 -> 1.137
---
Log message:
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.
---
Diffs of the changes: (+16 -0)
PPC32ISelSimple.cpp | 16 ++++++++++++++++
1 files changed, 16 insertions(+)
Index: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.136 llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.137
--- llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.136 Sat Apr 9 14:47:21 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp Sat Apr 9 17:05:17 2005
@@ -871,6 +871,16 @@
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 @@
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);
}
More information about the llvm-commits
mailing list