Implement a proper function list in module, which auto-maintain the parent
pointer, and ensure that functions are deleted when the module is destroyed.
This exposed the fact that MLFunction had no dtor, and that the dtor in
CFGFunction was broken with cyclic references. Fix both of these problems.
PiperOrigin-RevId: 206051666
diff --git a/lib/Transforms/LoopUnroll.cpp b/lib/Transforms/LoopUnroll.cpp
index af0c7ca..337f558 100644
--- a/lib/Transforms/LoopUnroll.cpp
+++ b/lib/Transforms/LoopUnroll.cpp
@@ -44,8 +44,8 @@
/// Unrolls all the innermost loops of this Module.
bool MLFunctionPass::runOnModule(Module *m) {
bool changed = false;
- for (auto fn : m->functionList) {
- if (auto *mlFunc = dyn_cast<MLFunction>(fn))
+ for (auto &fn : *m) {
+ if (auto *mlFunc = dyn_cast<MLFunction>(&fn))
changed |= runOnMLFunction(mlFunc);
}
return changed;