summaryrefslogtreecommitdiff
path: root/gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
diff options
context:
space:
mode:
authorPascal Stumpf <pascal@cvs.openbsd.org>2016-09-03 22:47:03 +0000
committerPascal Stumpf <pascal@cvs.openbsd.org>2016-09-03 22:47:03 +0000
commit687c86e3f9216c345144e295e589f0617c6dcaa7 (patch)
tree13eb34df345af9974e9a9204fd5720d68ab15c61 /gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
parent3eb026e03e65c74013af48f97f489a7d9ac98d6e (diff)
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp')
-rw-r--r--gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp b/gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
index ff44c5660ba..b11b49717c4 100644
--- a/gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
+++ b/gnu/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
@@ -11,18 +11,19 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/CodeGen/Passes.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetSubtargetInfo.h"
using namespace llvm;
-#define DEBUG_TYPE "dead-mi-elimination"
+#define DEBUG_TYPE "codegen-dce"
STATISTIC(NumDeletes, "Number of dead instructions deleted");
@@ -41,11 +42,6 @@ namespace {
initializeDeadMachineInstructionElimPass(*PassRegistry::getPassRegistry());
}
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.setPreservesCFG();
- MachineFunctionPass::getAnalysisUsage(AU);
- }
-
private:
bool isDead(const MachineInstr *MI) const;
};
@@ -53,7 +49,7 @@ namespace {
char DeadMachineInstructionElim::ID = 0;
char &llvm::DeadMachineInstructionElimID = DeadMachineInstructionElim::ID;
-INITIALIZE_PASS(DeadMachineInstructionElim, DEBUG_TYPE,
+INITIALIZE_PASS(DeadMachineInstructionElim, "dead-mi-elimination",
"Remove dead machine instructions", false, false)
bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {
@@ -94,7 +90,7 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {
}
bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
- if (skipFunction(MF.getFunction()))
+ if (skipOptnoneFunction(*MF.getFunction()))
return false;
bool AnyChanges = false;
@@ -109,7 +105,7 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
// Start out assuming that reserved registers are live out of this block.
LivePhysRegs = MRI->getReservedRegs();
- // Add live-ins from successors to LivePhysRegs. Normally, physregs are not
+ // Add live-ins from sucessors to LivePhysRegs. Normally, physregs are not
// live across blocks, but some targets (x86) can have flags live out of a
// block.
for (MachineBasicBlock::succ_iterator S = MBB.succ_begin(),
@@ -121,17 +117,20 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
// liveness as we go.
for (MachineBasicBlock::reverse_iterator MII = MBB.rbegin(),
MIE = MBB.rend(); MII != MIE; ) {
- MachineInstr *MI = &*MII++;
+ MachineInstr *MI = &*MII;
// If the instruction is dead, delete it!
if (isDead(MI)) {
- LLVM_DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI);
+ DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI);
// It is possible that some DBG_VALUE instructions refer to this
// instruction. They get marked as undef and will be deleted
// in the live debug variable analysis.
MI->eraseFromParentAndMarkDBGValuesForRemoval();
AnyChanges = true;
++NumDeletes;
+ MIE = MBB.rend();
+ // MII is now pointing to the next instruction to process,
+ // so don't increment it.
continue;
}
@@ -165,6 +164,10 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
}
}
}
+
+ // We didn't delete the current instruction, so increment MII to
+ // the next one.
+ ++MII;
}
}