[llvm-commits] [llvm] r78151 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/LowerSubregs.cpp test/CodeGen/Blackfin/printf2.ll
Evan Cheng
evan.cheng at apple.com
Tue Aug 4 20:53:22 PDT 2009
Author: evancheng
Date: Tue Aug 4 22:53:14 2009
New Revision: 78151
URL: http://llvm.org/viewvc/llvm-project?rev=78151&view=rev
Log:
Turn some insert_subreg, extract_subreg, subreg_to_reg into implicit_defs.
Modified:
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/lib/CodeGen/LowerSubregs.cpp
llvm/trunk/test/CodeGen/Blackfin/printf2.ll
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=78151&r1=78150&r2=78151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Aug 4 22:53:14 2009
@@ -106,6 +106,23 @@
}
}
+static bool CanTurnIntoImplicitDef(MachineInstr *MI, unsigned Reg,
+ const TargetInstrInfo *tii_) {
+ unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
+ if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
+ Reg == SrcReg)
+ return true;
+
+ if ((MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
+ MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG) &&
+ MI->getOperand(2).getReg() == Reg)
+ return true;
+ if (MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG &&
+ MI->getOperand(1).getReg() == Reg)
+ return true;
+ return false;
+}
+
/// processImplicitDefs - Process IMPLICIT_DEF instructions and make sure
/// there is one implicit_def for each use. Add isUndef marker to
/// implicit_def defs and their uses.
@@ -132,7 +149,7 @@
bool ChangedToImpDef = false;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
MachineOperand& MO = MI->getOperand(i);
- if (!MO.isReg() || !MO.isUse())
+ if (!MO.isReg() || !MO.isUse() || MO.isUndef())
continue;
unsigned Reg = MO.getReg();
if (!Reg)
@@ -140,9 +157,7 @@
if (!ImpDefRegs.count(Reg))
continue;
// Use is a copy, just turn it into an implicit_def.
- unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
- if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
- Reg == SrcReg) {
+ if (CanTurnIntoImplicitDef(MI, Reg, tii_)) {
bool isKill = MO.isKill();
MI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF));
for (int j = MI->getNumOperands() - 1, ee = 0; j > ee; --j)
@@ -154,8 +169,15 @@
}
MO.setIsUndef();
- if (MO.isKill() || MI->isRegTiedToDefOperand(i))
+ if (MO.isKill() || MI->isRegTiedToDefOperand(i)) {
+ // Make sure other uses of
+ for (unsigned j = i+1; j != e; ++j) {
+ MachineOperand &MOJ = MI->getOperand(j);
+ if (MOJ.isReg() && MOJ.isUse() && MOJ.getReg() == Reg)
+ MOJ.setIsUndef();
+ }
ImpDefRegs.erase(Reg);
+ }
}
if (ChangedToImpDef) {
Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=78151&r1=78150&r2=78151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original)
+++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Tue Aug 4 22:53:14 2009
@@ -119,6 +119,7 @@
"Extract supperg source must be a physical register");
assert(TargetRegisterInfo::isPhysicalRegister(DstReg) &&
"Extract destination must be in a physical register");
+ assert(SrcReg && "invalid subregister index for register");
DOUT << "subreg: CONVERTING: " << *MI;
Modified: llvm/trunk/test/CodeGen/Blackfin/printf2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Blackfin/printf2.ll?rev=78151&r1=78150&r2=78151&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Blackfin/printf2.ll (original)
+++ llvm/trunk/test/CodeGen/Blackfin/printf2.ll Tue Aug 4 22:53:14 2009
@@ -1,7 +1,4 @@
; RUN: llvm-as < %s | llc -march=bfin
-; XFAIL: *
-; Assertion failed: (isUsed(Reg) && "Using an undefined register!"),
-; function forward, file RegisterScavenging.cpp, line 182.
declare i32 @printf(i8*, ...)
More information about the llvm-commits
mailing list