blob: f0a06859e908817313a50cf0e180f940fae1451e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//===- llvm/Transforms/ChangeAllocations.h -----------------------*- C++ -*--=//
//
// This file defines two passes that convert malloc and free instructions to
// calls to and from %malloc & %free function calls. The LowerAllocations
// transformation is a target dependant tranformation because it depends on the
// size of data types and alignment constraints.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_CHANGEALLOCATIONS_H
#define LLVM_TRANSFORMS_CHANGEALLOCATIONS_H
#include "llvm/Pass.h"
class TargetData;
// LowerAllocations - Turn malloc and free instructions into %malloc and %free
// calls.
//
class LowerAllocations : public BasicBlockPass {
Method *MallocMeth; // Methods in the module we are processing
Method *FreeMeth; // Initialized by doInitialization
const TargetData &DataLayout;
public:
inline LowerAllocations(const TargetData &TD) : DataLayout(TD) {
MallocMeth = FreeMeth = 0;
}
// doPassInitialization - For the lower allocations pass, this ensures that a
// module contains a declaration for a malloc and a free function.
//
bool doInitialization(Module *M);
// runOnBasicBlock - This method does the actual work of converting
// instructions over, assuming that the pass has already been initialized.
//
bool runOnBasicBlock(BasicBlock *BB);
};
// RaiseAllocations - Turn %malloc and %free calls into the appropriate
// instruction.
//
class RaiseAllocations : public BasicBlockPass {
Method *MallocMeth; // Methods in the module we are processing
Method *FreeMeth; // Initialized by doPassInitializationVirt
public:
inline RaiseAllocations() : MallocMeth(0), FreeMeth(0) {}
// doPassInitialization - For the raise allocations pass, this finds a
// declaration for malloc and free if they exist.
//
bool doInitialization(Module *M);
// runOnBasicBlock - This method does the actual work of converting
// instructions over, assuming that the pass has already been initialized.
//
bool runOnBasicBlock(BasicBlock *BB);
};
#endif
|