1 //===- llvm/Transforms/LowerAllocations.h - Remove Malloc & Free -*- C++ -*--=//
3 // This file defines the interface to a pass that lowers malloc and free
4 // instructions to calls to %malloc & %free functions. This transformation is
5 // a target dependant tranformation because we depend on the size of data types
6 // and alignment constraints.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TRANSFORMS_LOWERALLOCATIONS_H
11 #define LLVM_TRANSFORMS_LOWERALLOCATIONS_H
13 #include "llvm/Transforms/Pass.h"
16 class LowerAllocations : public ConcretePass<LowerAllocations> {
17 Method *MallocMeth; // Methods in the module we are processing
18 Method *FreeMeth; // Initialized by doPassInitializationVirt
20 const TargetData &DataLayout;
22 inline LowerAllocations(const TargetData &TD) : DataLayout(TD) {
23 MallocMeth = FreeMeth = 0;
26 // doPassInitialization - For the lower allocations pass, this ensures that a
27 // module contains a declaration for a malloc and a free function.
29 // This function is always successful.
31 bool doPassInitializationVirt(Module *M);
33 // doPerMethodWork - This method does the actual work of converting
34 // instructions over, assuming that the pass has already been initialized.
36 bool doPerMethodWorkVirt(Method *M);