[llvm] r187299 - Fix a memory leak in the hexagon scheduler. We call initialize here more

Chandler Carruth chandlerc at gmail.com
Sat Jul 27 03:48:45 PDT 2013


Author: chandlerc
Date: Sat Jul 27 05:48:45 2013
New Revision: 187299

URL: http://llvm.org/viewvc/llvm-project?rev=187299&view=rev
Log:
Fix a memory leak in the hexagon scheduler. We call initialize here more
than once, and the second time through we leaked memory. Found thanks to
the vg-leak bot, but I can't locally reproduce it with valgrind. The
debugger confirms that it is in fact leaking here.

This whole code is totally gross. Why is initialize being called on each
runOnFunction??? Why aren't these OwningPtr<>s, and why aren't their
lifetimes better defined? Anyways, this is just a surgical change to
help out the leak checking bots.

Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp?rev=187299&r1=187298&r2=187299&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp Sat Jul 27 05:48:45 2013
@@ -208,6 +208,8 @@ void ConvergingVLIWScheduler::initialize
   Top.HazardRec = TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
   Bot.HazardRec = TM.getInstrInfo()->CreateTargetMIHazardRecognizer(Itin, DAG);
 
+  delete Top.ResourceModel;
+  delete Bot.ResourceModel;
   Top.ResourceModel = new VLIWResourceModel(TM, DAG->getSchedModel());
   Bot.ResourceModel = new VLIWResourceModel(TM, DAG->getSchedModel());
 





More information about the llvm-commits mailing list