projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DebugInfo: Emit DW_TAG_subprogram's DW_AT_high_pc as an offset from the low_pc
[oota-llvm.git]
/
lib
/
CodeGen
/
MachineCopyPropagation.cpp
diff --git
a/lib/CodeGen/MachineCopyPropagation.cpp
b/lib/CodeGen/MachineCopyPropagation.cpp
index 712e7414337de3889776b0d811035296be09d2f3..e41d3eee216a7c54901cf627bf1265213733f390 100644
(file)
--- a/
lib/CodeGen/MachineCopyPropagation.cpp
+++ b/
lib/CodeGen/MachineCopyPropagation.cpp
@@
-13,19
+13,19
@@
#define DEBUG_TYPE "codegen-cp"
#include "llvm/CodeGen/Passes.h"
#define DEBUG_TYPE "codegen-cp"
#include "llvm/CodeGen/Passes.h"
-#include "llvm/Pass.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/Target/TargetInstrInfo.h"
-#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/Statistic.h"
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetRegisterInfo.h"
using namespace llvm;
STATISTIC(NumDeletes, "Number of dead copies deleted");
using namespace llvm;
STATISTIC(NumDeletes, "Number of dead copies deleted");
@@
-127,13
+127,10
@@
static bool isNopCopy(MachineInstr *CopyMI, unsigned Def, unsigned Src,
}
// Remove MI from the function because it has been determined it is dead.
}
// Remove MI from the function because it has been determined it is dead.
-// Turn it into a noop KILL instruction
if it has super-register liveness
-//
adjustment
s.
+// Turn it into a noop KILL instruction
as opposed to removing it to
+//
maintain imp-use/imp-def chain
s.
void MachineCopyPropagation::removeCopy(MachineInstr *MI) {
void MachineCopyPropagation::removeCopy(MachineInstr *MI) {
- if (MI->getNumOperands() == 2)
- MI->eraseFromParent();
- else
- MI->setDesc(TII->get(TargetOpcode::KILL));
+ MI->setDesc(TII->get(TargetOpcode::KILL));
}
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
}
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
@@
-142,6
+139,8
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
DenseMap<unsigned, MachineInstr*> CopyMap; // Def -> copies map
SourceMap SrcMap; // Src -> Def map
DenseMap<unsigned, MachineInstr*> CopyMap; // Def -> copies map
SourceMap SrcMap; // Src -> Def map
+ DEBUG(dbgs() << "MCP: CopyPropagateBlock " << MBB.getName() << "\n");
+
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ) {
MachineInstr *MI = &*I;
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ) {
MachineInstr *MI = &*I;
@@
-176,6
+175,8
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
// CALL
// %RAX<def> = COPY %RSP
// CALL
// %RAX<def> = COPY %RSP
+ DEBUG(dbgs() << "MCP: copy is a NOP, removing: "; MI->dump());
+
// Clear any kills of Def between CopyMI and MI. This extends the
// live range.
for (MachineBasicBlock::iterator I = CopyMI, E = MI; I != E; ++I)
// Clear any kills of Def between CopyMI and MI. This extends the
// live range.
for (MachineBasicBlock::iterator I = CopyMI, E = MI; I != E; ++I)
@@
-191,10
+192,14
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
// If Src is defined by a previous copy, it cannot be eliminated.
for (MCRegAliasIterator AI(Src, TRI, true); AI.isValid(); ++AI) {
CI = CopyMap.find(*AI);
// If Src is defined by a previous copy, it cannot be eliminated.
for (MCRegAliasIterator AI(Src, TRI, true); AI.isValid(); ++AI) {
CI = CopyMap.find(*AI);
- if (CI != CopyMap.end())
+ if (CI != CopyMap.end()) {
+ DEBUG(dbgs() << "MCP: Copy is no longer dead: "; CI->second->dump());
MaybeDeadCopies.remove(CI->second);
MaybeDeadCopies.remove(CI->second);
+ }
}
}
+ DEBUG(dbgs() << "MCP: Copy is a deletion candidate: "; MI->dump());
+
// Copy is now a candidate for deletion.
MaybeDeadCopies.insert(MI);
// Copy is now a candidate for deletion.
MaybeDeadCopies.insert(MI);
@@
-213,9
+218,8
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
CopyMap.erase(*AI);
AvailCopyMap.erase(*AI);
}
CopyMap.erase(*AI);
AvailCopyMap.erase(*AI);
}
- CopyMap[Def] = MI;
- AvailCopyMap[Def] = MI;
- for (MCSubRegIterator SR(Def, TRI); SR.isValid(); ++SR) {
+ for (MCSubRegIterator SR(Def, TRI, /*IncludeSelf=*/true); SR.isValid();
+ ++SR) {
CopyMap[*SR] = MI;
AvailCopyMap[*SR] = MI;
}
CopyMap[*SR] = MI;
AvailCopyMap[*SR] = MI;
}
@@
-256,8
+260,10
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
// for elimination.
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
DenseMap<unsigned, MachineInstr*>::iterator CI = CopyMap.find(*AI);
// for elimination.
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
DenseMap<unsigned, MachineInstr*>::iterator CI = CopyMap.find(*AI);
- if (CI != CopyMap.end())
+ if (CI != CopyMap.end()) {
+ DEBUG(dbgs() << "MCP: Copy is used - not dead: "; CI->second->dump());
MaybeDeadCopies.remove(CI->second);
MaybeDeadCopies.remove(CI->second);
+ }
}
}
}
}
@@
-274,6
+280,8
@@
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
unsigned Reg = (*DI)->getOperand(0).getReg();
if (MRI->isReserved(Reg) || !MaskMO.clobbersPhysReg(Reg))
continue;
unsigned Reg = (*DI)->getOperand(0).getReg();
if (MRI->isReserved(Reg) || !MaskMO.clobbersPhysReg(Reg))
continue;
+ DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: ";
+ (*DI)->dump());
removeCopy(*DI);
Changed = true;
++NumDeletes;
removeCopy(*DI);
Changed = true;
++NumDeletes;