~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Analysis/PHITransAddr.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- PHITransAddr.h - PHI Translation for Addresses -----------*- C++ -*-===//
 
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 declares the PHITransAddr class.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_ANALYSIS_PHITRANSADDR_H
 
15
#define LLVM_ANALYSIS_PHITRANSADDR_H
 
16
 
 
17
#include "llvm/Instruction.h"
 
18
#include "llvm/ADT/SmallVector.h"
 
19
 
 
20
namespace llvm {
 
21
  class DominatorTree;
 
22
  class TargetData;
 
23
  
 
24
/// PHITransAddr - An address value which tracks and handles phi translation.
 
25
/// As we walk "up" the CFG through predecessors, we need to ensure that the
 
26
/// address we're tracking is kept up to date.  For example, if we're analyzing
 
27
/// an address of "&A[i]" and walk through the definition of 'i' which is a PHI
 
28
/// node, we *must* phi translate i to get "&A[j]" or else we will analyze an
 
29
/// incorrect pointer in the predecessor block.
 
30
///
 
31
/// This is designed to be a relatively small object that lives on the stack and
 
32
/// is copyable.
 
33
///
 
34
class PHITransAddr {
 
35
  /// Addr - The actual address we're analyzing.
 
36
  Value *Addr;
 
37
  
 
38
  /// TD - The target data we are playing with if known, otherwise null.
 
39
  const TargetData *TD;
 
40
  
 
41
  /// InstInputs - The inputs for our symbolic address.
 
42
  SmallVector<Instruction*, 4> InstInputs;
 
43
public:
 
44
  PHITransAddr(Value *addr, const TargetData *td) : Addr(addr), TD(td) {
 
45
    // If the address is an instruction, the whole thing is considered an input.
 
46
    if (Instruction *I = dyn_cast<Instruction>(Addr))
 
47
      InstInputs.push_back(I);
 
48
  }
 
49
  
 
50
  Value *getAddr() const { return Addr; }
 
51
  
 
52
  /// NeedsPHITranslationFromBlock - Return true if moving from the specified
 
53
  /// BasicBlock to its predecessors requires PHI translation.
 
54
  bool NeedsPHITranslationFromBlock(BasicBlock *BB) const {
 
55
    // We do need translation if one of our input instructions is defined in
 
56
    // this block.
 
57
    for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
 
58
      if (InstInputs[i]->getParent() == BB)
 
59
        return true;
 
60
    return false;
 
61
  }
 
62
  
 
63
  /// IsPotentiallyPHITranslatable - If this needs PHI translation, return true
 
64
  /// if we have some hope of doing it.  This should be used as a filter to
 
65
  /// avoid calling PHITranslateValue in hopeless situations.
 
66
  bool IsPotentiallyPHITranslatable() const;
 
67
  
 
68
  /// PHITranslateValue - PHI translate the current address up the CFG from
 
69
  /// CurBB to Pred, updating our state to reflect any needed changes.  If the
 
70
  /// dominator tree DT is non-null, the translated value must dominate
 
71
  /// PredBB.  This returns true on failure and sets Addr to null.
 
72
  bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB,
 
73
                         const DominatorTree *DT);
 
74
  
 
75
  /// PHITranslateWithInsertion - PHI translate this value into the specified
 
76
  /// predecessor block, inserting a computation of the value if it is
 
77
  /// unavailable.
 
78
  ///
 
79
  /// All newly created instructions are added to the NewInsts list.  This
 
80
  /// returns null on failure.
 
81
  ///
 
82
  Value *PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB,
 
83
                                   const DominatorTree &DT,
 
84
                                   SmallVectorImpl<Instruction*> &NewInsts);
 
85
  
 
86
  void dump() const;
 
87
  
 
88
  /// Verify - Check internal consistency of this data structure.  If the
 
89
  /// structure is valid, it returns true.  If invalid, it prints errors and
 
90
  /// returns false.
 
91
  bool Verify() const;
 
92
private:
 
93
  Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB,
 
94
                             const DominatorTree *DT);
 
95
  
 
96
  /// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated
 
97
  /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
 
98
  /// block.  All newly created instructions are added to the NewInsts list.
 
99
  /// This returns null on failure.
 
100
  ///
 
101
  Value *InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
 
102
                                    BasicBlock *PredBB, const DominatorTree &DT,
 
103
                                    SmallVectorImpl<Instruction*> &NewInsts);
 
104
  
 
105
  /// AddAsInput - If the specified value is an instruction, add it as an input.
 
106
  Value *AddAsInput(Value *V) {
 
107
    // If V is an instruction, it is now an input.
 
108
    if (Instruction *VI = dyn_cast<Instruction>(V))
 
109
      InstInputs.push_back(VI);
 
110
    return V;
 
111
  }
 
112
  
 
113
};
 
114
 
 
115
} // end namespace llvm
 
116
 
 
117
#endif