[llvm-commits] [llvm] r90501 - /llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp
Evan Cheng
evan.cheng at apple.com
Thu Dec 3 16:09:06 PST 2009
Author: evancheng
Date: Thu Dec 3 18:09:05 2009
New Revision: 90501
URL: http://llvm.org/viewvc/llvm-project?rev=90501&view=rev
Log:
- If the reaching definition is an undef and the use is a PHI, add the implicit_def to the end of the source block.
- When reaching value is replaced with another, update the cache as well.
Modified:
llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp
Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90501&r1=90500&r2=90501&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Thu Dec 3 18:09:05 2009
@@ -194,17 +194,22 @@
if (UseMI->getOpcode() == TargetInstrInfo::PHI) {
MachineBasicBlock *SourceBB = findCorrespondingPred(UseMI, &U);
NewVR = GetValueAtEndOfBlock(SourceBB);
- } else {
- NewVR = GetValueInMiddleOfBlock(UseMI->getParent());
- }
-
- if (NewVR == ~0U) {
// Insert an implicit_def to represent an undef value.
MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF,
- UseMI->getParent(), UseMI, VRC,MRI,TII);
+ SourceBB,SourceBB->getFirstTerminator(),
+ VRC, MRI, TII);
NewVR = NewDef->getOperand(0).getReg();
+ } else {
+ NewVR = GetValueInMiddleOfBlock(UseMI->getParent());
+ if (NewVR == ~0U) {
+ // Insert an implicit_def to represent an undef value.
+ MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF,
+ UseMI->getParent(), UseMI,
+ VRC, MRI, TII);
+ NewVR = NewDef->getOperand(0).getReg();
+ }
}
-
+
U.setReg(NewVR);
}
@@ -281,7 +286,7 @@
/// this block is involved in a loop, a no-entry PHI node will have been
/// inserted as InsertedVal. Otherwise, we'll still have the null we inserted
/// above.
- unsigned InsertedVal = AvailableVals[BB];
+ unsigned &InsertedVal = AvailableVals[BB];
// If all the predecessor values are the same then we don't need to insert a
// PHI. This is the simple and common case.
@@ -294,10 +299,10 @@
assert(InsertedVal != SingularValue && "Dead loop?");
MRI->replaceRegWith(InsertedVal, SingularValue);
OldVal->eraseFromParent();
- } else {
- InsertedVal = SingularValue;
}
+ InsertedVal = SingularValue;
+
// Drop the entries we added in IncomingPredInfo to restore the stack.
IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry,
IncomingPredInfo.end());
@@ -348,5 +353,4 @@
}
return InsertedVal;
-
}
More information about the llvm-commits
mailing list