Fix a leak in the FastISel code that Chris pointed out.
authorDan Gohman <gohman@apple.com>
Wed, 20 Aug 2008 00:56:17 +0000 (00:56 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 20 Aug 2008 00:56:17 +0000 (00:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55031 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/FastISel.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index b395e9710f131939ac439ce57351af4e9769bdac..a241756df5b32733072a4296adf08237199153ee 100644 (file)
@@ -43,13 +43,13 @@ public:
   SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
                      DenseMap<const Value*, unsigned> &ValueMap);
 
+  virtual ~FastISel();
+
 protected:
   FastISel(MachineBasicBlock *mbb, MachineFunction *mf,
            const TargetInstrInfo *tii)
     : MBB(mbb), MF(mf), TII(tii) {}
 
-  virtual ~FastISel();
-
   /// FastEmit_r - This method is called by target-independent code
   /// to request that an instruction with the given type and opcode
   /// be emitted.
index 6a626b90e3e9ffac310caf0410a164418958348a..1536a641a609dccc268eb82c36df4b4a02497583 100644 (file)
@@ -5115,6 +5115,14 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
     if (FastISel *F = TLI.createFastISel(BB, &FuncInfo.MF,
                                        TLI.getTargetMachine().getInstrInfo())) {
       Begin = F->SelectInstructions(Begin, LLVMBB->end(), FuncInfo.ValueMap);
+
+      // Clean up the FastISel object. TODO: Reorganize what data is
+      // stored in the FastISel class itself and what is merely passed
+      // to the SelectInstructions method, and then move the creation
+      // and deletion of the FastISel object up so that it is only
+      // done once per MachineFunction.
+      delete F;
+
       if (Begin == LLVMBB->end())
         // The "fast" selector selected the entire block, so we're done.
         return;