[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerAllocations.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Sep 25 18:48:01 PDT 2002


Changes in directory llvm/lib/Transforms/Scalar:

LowerAllocations.cpp updated: 1.31 -> 1.32

---
Log message:


Change LowerAllocations pass to 'require' TargetData instead of it being
passed in.



---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.31 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.32
--- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.31	Tue Sep 10 17:38:47 2002
+++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp	Wed Sep 25 18:47:47 2002
@@ -20,40 +20,39 @@
 
 namespace {
 
-// LowerAllocations - Turn malloc and free instructions into %malloc and %free
-// calls.
-//
-class LowerAllocations : public BasicBlockPass {
-  Function *MallocFunc;   // Functions in the module we are processing
-  Function *FreeFunc;     // Initialized by doInitialization
-
-  const TargetData &DataLayout;
-public:
-  LowerAllocations(const TargetData &TD) : DataLayout(TD) {
-    MallocFunc = FreeFunc = 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);
-};
+  /// LowerAllocations - Turn malloc and free instructions into %malloc and
+  /// %free calls.
+  ///
+  class LowerAllocations : public BasicBlockPass {
+    Function *MallocFunc;   // Functions in the module we are processing
+    Function *FreeFunc;     // Initialized by doInitialization
+  public:
+    LowerAllocations() : MallocFunc(0), FreeFunc(0) {}
+
+    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+      AU.addRequired<TargetData>();
+    }
+
+    /// 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);
+  };
+
+  RegisterOpt<LowerAllocations>
+  X("lowerallocs", "Lower allocations from instructions to calls");
 }
 
 // createLowerAllocationsPass - Interface to this file...
-Pass *createLowerAllocationsPass(const TargetData &TD) {
-  return new LowerAllocations(TD);
+Pass *createLowerAllocationsPass() {
+  return new LowerAllocations();
 }
 
-static RegisterOpt<LowerAllocations>
-X("lowerallocs", "Lower allocations from instructions to calls (TD)",
-  createLowerAllocationsPass);
-
 
 // doInitialization - For the lower allocations pass, this ensures that a
 // module contains a declaration for a malloc and a free function.
@@ -83,6 +82,7 @@
   assert(MallocFunc && FreeFunc && "Pass not initialized!");
 
   BasicBlock::InstListType &BBIL = BB.getInstList();
+  TargetData &DataLayout = getAnalysis<TargetData>();
 
   // Loop over all of the instructions, looking for malloc or free instructions
   for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {





More information about the llvm-commits mailing list