~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Transforms/Scalar/DCE.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements dead inst elimination and dead code elimination.
 
11
//
 
12
// Dead Inst Elimination performs a single pass over the function removing
 
13
// instructions that are obviously dead.  Dead Code Elimination is similar, but
 
14
// it rechecks instructions that were used by removed instructions to see if
 
15
// they are newly dead.
 
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/InstIterator.h"
 
25
#include "llvm/ADT/Statistic.h"
 
26
#include <set>
 
27
using namespace llvm;
 
28
 
 
29
STATISTIC(DIEEliminated, "Number of insts removed by DIE pass");
 
30
STATISTIC(DCEEliminated, "Number of insts removed");
 
31
 
 
32
namespace {
 
33
  //===--------------------------------------------------------------------===//
 
34
  // DeadInstElimination pass implementation
 
35
  //
 
36
  struct DeadInstElimination : public BasicBlockPass {
 
37
    static char ID; // Pass identification, replacement for typeid
 
38
    DeadInstElimination() : BasicBlockPass(ID) {}
 
39
    virtual bool runOnBasicBlock(BasicBlock &BB) {
 
40
      bool Changed = false;
 
41
      for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
 
42
        Instruction *Inst = DI++;
 
43
        if (isInstructionTriviallyDead(Inst)) {
 
44
          Inst->eraseFromParent();
 
45
          Changed = true;
 
46
          ++DIEEliminated;
 
47
        }
 
48
      }
 
49
      return Changed;
 
50
    }
 
51
 
 
52
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
53
      AU.setPreservesCFG();
 
54
    }
 
55
  };
 
56
}
 
57
 
 
58
char DeadInstElimination::ID = 0;
 
59
INITIALIZE_PASS(DeadInstElimination, "die",
 
60
                "Dead Instruction Elimination", false, false);
 
61
 
 
62
Pass *llvm::createDeadInstEliminationPass() {
 
63
  return new DeadInstElimination();
 
64
}
 
65
 
 
66
 
 
67
namespace {
 
68
  //===--------------------------------------------------------------------===//
 
69
  // DeadCodeElimination pass implementation
 
70
  //
 
71
  struct DCE : public FunctionPass {
 
72
    static char ID; // Pass identification, replacement for typeid
 
73
    DCE() : FunctionPass(ID) {}
 
74
 
 
75
    virtual bool runOnFunction(Function &F);
 
76
 
 
77
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
78
      AU.setPreservesCFG();
 
79
    }
 
80
 };
 
81
}
 
82
 
 
83
char DCE::ID = 0;
 
84
INITIALIZE_PASS(DCE, "dce", "Dead Code Elimination", false, false);
 
85
 
 
86
bool DCE::runOnFunction(Function &F) {
 
87
  // Start out with all of the instructions in the worklist...
 
88
  std::vector<Instruction*> WorkList;
 
89
  for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
 
90
    WorkList.push_back(&*i);
 
91
 
 
92
  // Loop over the worklist finding instructions that are dead.  If they are
 
93
  // dead make them drop all of their uses, making other instructions
 
94
  // potentially dead, and work until the worklist is empty.
 
95
  //
 
96
  bool MadeChange = false;
 
97
  while (!WorkList.empty()) {
 
98
    Instruction *I = WorkList.back();
 
99
    WorkList.pop_back();
 
100
 
 
101
    if (isInstructionTriviallyDead(I)) {       // If the instruction is dead.
 
102
      // Loop over all of the values that the instruction uses, if there are
 
103
      // instructions being used, add them to the worklist, because they might
 
104
      // go dead after this one is removed.
 
105
      //
 
106
      for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI)
 
107
        if (Instruction *Used = dyn_cast<Instruction>(*OI))
 
108
          WorkList.push_back(Used);
 
109
 
 
110
      // Remove the instruction.
 
111
      I->eraseFromParent();
 
112
 
 
113
      // Remove the instruction from the worklist if it still exists in it.
 
114
      for (std::vector<Instruction*>::iterator WI = WorkList.begin();
 
115
           WI != WorkList.end(); ) {
 
116
        if (*WI == I)
 
117
          WI = WorkList.erase(WI);
 
118
        else
 
119
          ++WI;
 
120
      }
 
121
 
 
122
      MadeChange = true;
 
123
      ++DCEEliminated;
 
124
    }
 
125
  }
 
126
  return MadeChange;
 
127
}
 
128
 
 
129
FunctionPass *llvm::createDeadCodeEliminationPass() {
 
130
  return new DCE();
 
131
}
 
132