Deleted Added
sdiff udiff text old ( 193323 ) new ( 198090 )
full compact
1//===- DCE.cpp - Code to perform dead code elimination --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 7 unchanged lines hidden (view full) ---

16//
17//===----------------------------------------------------------------------===//
18
19#define DEBUG_TYPE "dce"
20#include "llvm/Transforms/Scalar.h"
21#include "llvm/Transforms/Utils/Local.h"
22#include "llvm/Instruction.h"
23#include "llvm/Pass.h"
24#include "llvm/Support/Compiler.h"
25#include "llvm/Support/InstIterator.h"
26#include "llvm/ADT/Statistic.h"
27#include <set>
28using namespace llvm;
29
30STATISTIC(DIEEliminated, "Number of insts removed by DIE pass");
31STATISTIC(DCEEliminated, "Number of insts removed");
32
33namespace {
34 //===--------------------------------------------------------------------===//
35 // DeadInstElimination pass implementation
36 //
37 struct VISIBILITY_HIDDEN DeadInstElimination : public BasicBlockPass {
38 static char ID; // Pass identification, replacement for typeid
39 DeadInstElimination() : BasicBlockPass(&ID) {}
40 virtual bool runOnBasicBlock(BasicBlock &BB) {
41 bool Changed = false;
42 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
43 Instruction *Inst = DI++;
44 if (isInstructionTriviallyDead(Inst)) {
45 Inst->eraseFromParent();

--- 88 unchanged lines hidden ---